Setting focus on a new record in subform

shandoo27

Registered User.
Local time
Today, 11:33
Joined
May 20, 2010
Messages
30
I have a main form with a button add and a subform which is bounded to a given table.

I want the add button to work like this:
When add button is clicked, It has to set focus on the first column of the new record in the subform and then after the user enters data into all the columns in the subform , after entering the last value and pressing enter it must automatically load this into the table.

Could anyone pls help me out with a VBA code suitable with this ??
 
Code:
Private Sub Button_Click()
With Me![COLOR=red]NameOfSubformControl[/COLOR]
      .SetFocus
      .Form![COLOR=red]NameOfFirstControl[/COLOR].SetFocus
End With
End Sub

Change the redparts with your own names for your form controls.

Since the subform is BOUND to a table, it will save automaticly as soon as you leave the record

JR
 
yes i have done the above , but my purpose of having an add button is because I dont want that row to be added directly because a few of the total field columns of the table have been bounded, the rest of the values are there in the textboxes in main form. So once the user enters the values in the subform, my add should take values from here and from the main form and insert into the table.

This is my problem. Now how do i set focus on the new record automatically. By ur method it will set focus on the first row's column and not the new row.
 
Not sure about your design and methode but how about:

Code:
Private Sub Button_Click()
With Me![COLOR=red]NameOfSubformControl[/COLOR]
      .SetFocus
      DoCmd.GoToRecord,,acNewRec
End With
End Sub

By ur method it will set focus on the first row's column and not the new row

A "Row" is a record is it not...;)

JR
 
Hi,

I did as you told above but there is no change , it is still focussing on the starting row first column as usual. any other way to achieve it ?
 

Users who are viewing this thread

Back
Top Bottom