Updating Main form field key value from subform

G

Guest

I have a subform, in this subform I have a list records. I created a command
button to set focus on record in list and then send a key value to mainform.
The value of the combo box on the main form does show the key value that I
sent from the subform but it seems not to recognize the value. If I click
onto the combo box on the main form and hit enter the record moves to the
next record in the list. If I change delete one character in the key value
and enter that same character and hit enter the value then displays properly.
It seems the combo box is not aware of the new key valuve that was sent to
even though it is displayed. Here is the code that I attached to the command
button on the subform to do this....

Private Sub Command16_Click()
Dim ctl As Control
Dim rs As Object
Forms![Form1].[Vt subform].Form![VRC_NumberLL].SetFocus
Forms![Form1]![Combo56] = Forms![Form1].[Vt subform].Form![VRC_NumberLL]

Set ctl = Forms!Form1!Combo56
DoCmd.GoToControl ctl.Name

Set rs = Me.Recordset.Clone
rs.FindFirst "[VRC_Number] = " & Str(Nz(Forms!Form1![Combo56], 0))
If Not rs.EOF Then Me.Bookmark = rs.Bookmark

End Sub
 
G

Guest

I have solved this problem. When the command button is clicked on the
subform to populate the combo control on the 3rd tab page of a tab control
object, the record lookup code from the command button does not work, in
spite of the fact that I set the focus to that combo box. I created an
update event on the 3rd tab page. Now the 3rd tab page, once I set the focus
to the combo box on that page, does a record lookup based on that key value.

I have tried absolute references to the combo box on the 3rd tab page but
this did not work either. It only works once the 3rd tab page is visible
with a subsequent record lookup.

Revised code for those who are interested is:

Button on subform with on_click event contains:

Dim ctl As Control
Forms![Form1]![Combo56] = Forms![Form1].[Vt subform].Form![VRC_NumberLL]
Set ctl = Forms!Form1!VRC_TypeT
DoCmd.GoToControl ctl.Name

On_change event for tab control contains:

Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[VRC_Number] = " & Str(Nz(Me![Combo56], 0))
If Not rs.EOF Then Me.Bookmark = rs.Bookmark


That's it. Works like a champ. I have multiple tab control pages each with
subforms that can now update the combo box which then brings up the detail
record for editing, etc.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top