Agree with Rick that the normal way of doing this would be a subform.
However, if you have two forms open on screen at any given time, and when
you select a new JobNumber on the Main form, you want to go to that job
number on the Service form, then you could put code similiar to the following
in the Current event of frmMain.
This checks to see if frmService is open, and if not, just ignores the rest
of the code.
Then it checks to see if frmMain is on a new record, and if so, it hides
frmService and skips the rest of the code.
It then creates a recordset based on frmServices underlying dataset,
searches that recordset for a JobNumber match, and if it finds one, moves
frmService to that job number and makes the form visible. If it does not
find the job number, it hides frmService.
Private Sub Form_Current
Dim frm as form
Dim strCriteria as string
dim rs as DAO.Recordset 'requires a reference to DAO in you project
'you only want to do this if frmService is open too
if currentproject.allforms("frmService").IsLoaded Then
Set frm = forms("frmService")
'if frmMain is on a new record, you need to hide frmService
frm.visible = NOT me.newrecord
if frm.visible Then
Set rs = frm.recordsetclone
strCriteria = "[Job_Number] = " & me.txt_JobNumber
rs.findfirst strCriteria
'if match found, move to the appropriate record in frmService
if rs.nomatch then
msgbox "No match found for frmService"
frm.visible = false
else
frm.bookmark = rs.bookmark
frm.visible = true
endif
rs.close
set rs = nothing
end if
end if
end sub
This is air code, so it may need tweaking!
HTH
Dale
--
Don''t forget to rate the post if it was helpful!
email address is invalid
Please reply to newsgroup only.
Matt said:
Is it possible to like two forms together via a certain field? Specifically,
I do most filing of info off of the "Job Number". I want to link the service
form to the main job form, ie when I switch records in the job form, can I
make it jump to the corresponding Job Number <both forms have the same Job
Number field linked> on the service form automatically? I'm using a tabbed
layout. If this doesn't make sense to anyone reading it, I will try to
clarify. Thanks in advance!