From: g on
I have created a form which has 5 fields of a Table as textboxes. The
table has 10 fields. I have added buttons for adding a new record,
saving it and browsing to next, previous record, first record and last
record in table.

For the onclick event of button new record, I added below code

Dim dbMyDB As DAO.Database
Dim myRecordSet As DAO.Recordset

Set dbMyDB = DBEngine.Workspaces(0).OpenDatabase("C:\mydatabase.accdb")
Set myRecordSet = dbMyDB.OpenRecordset("Table1", dbOpenDynaset)

myRecordSet.AddNew


myRecordSet.Close
dbMyDB.Close

which is incomplete.

1. What more do i need to add so that when it is clicked the user gets
five empty text boxes to which he can enter data which will add a new
record to the table(after the update button is clicked).

2. Similarly, for the buttons update, move to next, previous record,
first record, last, record, saving the added record is there a site/link
to tutorial which explains how to do these basic tasks for Access 2007.

Thanks
From: Salad on
g wrote:
> I have created a form which has 5 fields of a Table as textboxes. The
> table has 10 fields. I have added buttons for adding a new record,
> saving it and browsing to next, previous record, first record and last
> record in table.
>
> For the onclick event of button new record, I added below code
>
> Dim dbMyDB As DAO.Database
> Dim myRecordSet As DAO.Recordset
>
> Set dbMyDB = DBEngine.Workspaces(0).OpenDatabase("C:\mydatabase.accdb")
> Set myRecordSet = dbMyDB.OpenRecordset("Table1", dbOpenDynaset)
>
> myRecordSet.AddNew
>
>
> myRecordSet.Close
> dbMyDB.Close
>
> which is incomplete.
>
> 1. What more do i need to add so that when it is clicked the user gets
> five empty text boxes to which he can enter data which will add a new
> record to the table(after the update button is clicked).
>
> 2. Similarly, for the buttons update, move to next, previous record,
> first record, last, record, saving the added record is there a site/link
> to tutorial which explains how to do these basic tasks for Access 2007.
>
> Thanks

Is your form bound to a table/query or unbound?

If bound, why not use navigation buttons? Ex: use the New Form wizard
to help you create a data entry form to get you started.

If bound, you could use a command similar to
DoCmd.GoToRecord , , acNewRec
for code behind a command button to add a new record. Look at
GoToRecord for further options.

You might want to check to see if the record has been modified.
If Me.Dirty then...

You might want to see if the record is new or old.
If Me.NewRecord then...

If you want to move to a particular field, in this case field Test
Me.Test.Setfocus

I don't know about tutorials. I'd recommend a look at Google or some
other search engine.


From: g on
On 6/24/2010 2:11 PM, Salad wrote:
> g wrote:
>> I have created a form which has 5 fields of a Table as textboxes. The
>> table has 10 fields. I have added buttons for adding a new record,
>> saving it and browsing to next, previous record, first record and last
>> record in table.
>>
>> For the onclick event of button new record, I added below code
>>
>> Dim dbMyDB As DAO.Database
>> Dim myRecordSet As DAO.Recordset
>>
>> Set dbMyDB = DBEngine.Workspaces(0).OpenDatabase("C:\mydatabase.accdb")
>> Set myRecordSet = dbMyDB.OpenRecordset("Table1", dbOpenDynaset)
>>
>> myRecordSet.AddNew
>>
>>
>> myRecordSet.Close
>> dbMyDB.Close
>>
>> which is incomplete.
>>
>> 1. What more do i need to add so that when it is clicked the user gets
>> five empty text boxes to which he can enter data which will add a new
>> record to the table(after the update button is clicked).
>>
>> 2. Similarly, for the buttons update, move to next, previous record,
>> first record, last, record, saving the added record is there a
>> site/link to tutorial which explains how to do these basic tasks for
>> Access 2007.
>>
>> Thanks
>
> Is your form bound to a table/query or unbound?

It is bound to a table.

> If bound, why not use navigation buttons? Ex: use the New Form wizard to
> help you create a data entry form to get you started.

I see the button wizard now activated after i drag and drop a button.
The Use Control Wizards(with a wand icon) was turned off. Once i turned
it on, did drag/drop for a button it worked fine.


> If bound, you could use a command similar to
> DoCmd.GoToRecord , , acNewRec
> for code behind a command button to add a new record. Look at GoToRecord
> for further options.
>
> You might want to check to see if the record has been modified.
> If Me.Dirty then...
>
> You might want to see if the record is new or old.
> If Me.NewRecord then...
>
> If you want to move to a particular field, in this case field Test
> Me.Test.Setfocus
>
> I don't know about tutorials. I'd recommend a look at Google or some
> other search engine.

Thanks for the reply and advice.



From: g on
On 6/24/2010 2:27 PM, John W. Vinson wrote:
> On Thu, 24 Jun 2010 13:16:10 -0400, g<g_1(a)g.com> wrote:
>
>> I have created a form which has 5 fields of a Table as textboxes. The
>> table has 10 fields. I have added buttons for adding a new record,
>> saving it and browsing to next, previous record, first record and last
>> record in table.
>
> It really sounds like you're writing a lot of code and going to a whole lot of
> work to do something that a simple bound form does for you all by itself. Why?
> Have you used the builtin tools (a continous Form with navigation buttons
> turned on, as they will be by default) and intentionally rejected them? If so
> why?

I see the button wizard now activated after i drag and drop a button.
The Use Control Wizards(with a wand icon) was turned off. Once i turned
it on, did drag/drop for a button it worked fine.

I did not know that a simple bound form did that, by itself.