Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with moving to a specific record

Status
Not open for further replies.

carolla

Technical User
May 14, 2004
15
0
0
CA
I have a vehicle maintenance database that I’m having a problem with. There is a main form with subforms: frmMaster!frmVehicle!frmVehicleLog. On frmVehicle, there is a button that indicates how many outstanding work orders there are for that particular vehicle. When you click on that button, another form pops up that has a list of the outstanding work orders for that vehicle. There is a button on the detail section of the outstanding work orders form, that when clicked, I would like the form to close, set the focus to frmVehicleLog and go to the matching record that was selected from the outstanding work order form (because the work orders are included in frmVehicleLog). The [ServiceID] field is the common field. The data from both forms is stored in the same table (tblServiceLog) with different queries being used for the sources of the forms.
I can close the form and set the focus to frmVehicleLog, but I can’t get the correct code to move to the matching service record.
 
So I'm guessing the work orders are listed in a subform on the frmVehicleLog form(?)

Is this subform in continuous or datasheet view?

A quick way to do this would be to filter the subform for the particular record you are looking for. This will make only the chosen record show up in the subform so I'm not sure if this is really what you want.

If you want to go to that specific record while still being able to see all the other records, I think you'd need to use the move, seek or find methods of a dao recordset depending on what kind of query you have as your record source.
 
How are ya carolla . . .

In the button code of the opened form add the following line after you set focus & before you close the form:

Try the following, filling in names in [purple]purple[/purple]
Code:
[blue]   Dim frm As Form, Cri As String
   
   Set frm = Forms!frmMaster.Form!frmVehicle.Form!frmVehicleLog.Form
   Cri = "[ServiceID] = [red][b]'[/b][/red]" & Me!ServiceID & "[red][b]'[/b][/red]"
   
   frm.Recordset.FindFirst Cri
   [green]'set focus to frmVechileLog[/green]
   DoCmd.Close acForm, "[purple][B][I]FormName[/I][/B][/purple]"[/blue]
Note: if [blue]ServiceID[/blue] is numeric ... drop the two single quotes in [red]red[/red].

[blue]Your Thoughts? . . .[/blue]

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
Thank you to the both of you for such quick responses.
AceMan...I put your code in and it worked like a charm. I spent so much time on this one and just couldn't get it right. (And yes, I did have to drop the red quotes)
Thanks again,
Carolla
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top