subform problem (1 Viewer)

Pelerin13

Registered User.
Local time
Today, 05:52
Joined
Mar 23, 2011
Messages
56
Hey All,
I have a main form and 2 subforms inside it. And I when I click a field in first subform I want the cursor to move to the second subform and set 2 field value and then leave the focus on anther field in same subform.
So far I got the part to move and set the value, but the problem is that it doesn’t move a new record and the focus doesn’t stay

Code:
[/FONT][/SIZE]
[SIZE=3][FONT=Calibri]Private Sub Text18_Click() ' this field is in the 1st subform[/FONT][/SIZE]
[SIZE=3][FONT=Calibri]Dim partN As String[/FONT][/SIZE]
[SIZE=3][FONT=Calibri]partN = Me.Parts.Value ' this parts field is in the 1st subform[/FONT][/SIZE]
[SIZE=3][FONT=Calibri]Form_SO_ING_Serial_subform.PartNumber.Value = partN ' this parts field is in the 2ed subform[/FONT][/SIZE]
[SIZE=3][FONT=Calibri]Form_SO_ING_Serial_subform.Parts.Value = partN   ' this parts field is in the 2ed subform[/FONT][/SIZE]
[SIZE=3][FONT=Calibri]Form_SO_ING_Serial_subform.SerialNumberl.SetFocus ' this parts field is in the 2ed subform[/FONT][/SIZE]
[SIZE=3][FONT=Calibri]End Sub[/FONT][/SIZE]
[SIZE=3][FONT=Calibri]


Please help,
Pelerin
 

Pelerin13

Registered User.
Local time
Today, 05:52
Joined
Mar 23, 2011
Messages
56
i got the part to go to new record by adding this line

Form_SO_ING_Serial_subform.Recordset.AddNew

but I still want to setFocus on serialNumber
 

Pelerin13

Registered User.
Local time
Today, 05:52
Joined
Mar 23, 2011
Messages
56
any idea please?
 

CBrighton

Surfing while working...
Local time
Today, 12:52
Joined
Nov 9, 2010
Messages
1,012
Try setting the focus to that subform first, then to the actual control.

Something like:
Code:
[FONT=Calibri][SIZE=3]Form_SO_ING_Serial_subform.SetFocus[/SIZE][/FONT]
[FONT=Calibri][SIZE=3]Form_SO_ING_Serial_subform.SerialNumberl.SetFocus ' this parts field is in the 2nd subform[/SIZE][/FONT]

:edit:

Double checked code in my existing database and I do the same thing with code as above. Focus form then control.
 

Pelerin13

Registered User.
Local time
Today, 05:52
Joined
Mar 23, 2011
Messages
56
Thanks for the replay,
i tried that before and i get a Run time error '2449'
There is an invalid method in an expression.
and stoped at Form_SO_ING_Serial_subform.SetFocus
 

CBrighton

Surfing while working...
Local time
Today, 12:52
Joined
Nov 9, 2010
Messages
1,012
Is the form name correct? I have noticed that you are refering to the subform directly rather than via the main form (i.e. [FornName]![SubFormControlName].form![ControlName]) so tweaking that may help too.

Here is a piece of code from my database which works perfectly:

Code:
Me!subFindProfileResults.SetFocus
Me!subFindProfileResults.Form!btnOpenProfile.SetFocus

Same concept, focus the subform then a command button on the subform.
 

Pelerin13

Registered User.
Local time
Today, 05:52
Joined
Mar 23, 2011
Messages
56
there is something!!
i change the code, so i only have this 2 line on button click code
Code:
Me!SO_ING_Serial_subform.SetFocus
Me!SO_ING_Serial_subform.Form!SerialNumberl.SetFocus

and i'm still getting the error at SO_ING_Serial_subform
it says " Can't find the field 'SO_ING_Serial_subform'
 

CBrighton

Surfing while working...
Local time
Today, 12:52
Joined
Nov 9, 2010
Messages
1,012
Is "SO_ING_Serial_subform" the name of the subform control?

Doesn't matter what the subform itself is named, you have to use the name of the subform control.
 

Pelerin13

Registered User.
Local time
Today, 05:52
Joined
Mar 23, 2011
Messages
56
yes and they are the same name anyway SO_ING_Serial_subform
 

Pelerin13

Registered User.
Local time
Today, 05:52
Joined
Mar 23, 2011
Messages
56
i had to use Macros to get it to work
thanks anyways
 

Users who are viewing this thread

Top Bottom