Linking forms

M

Matt

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!
 
R

Rick A.B.

Is it possible to like two forms together via a certain field?  Specifically,
Matt,

Without knowing more, it sounds like this would be a perfect place for
a sublform. If you place your service form on your main form as
subform you can link it to the main form form the Child/Parent
properties for the subform control. If that's not what your looking
for then give us some more information.

Rick
 
D

Dale Fye

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
 
M

Matt

I have to be able to view both forms at the same time, and I could just see
everyone changing to a certain record on one form, then modifying the other
form that should correspond without first changing to the related record.
Thanks a lot to both of you guys for your insight!
--
"The only thing worse than an employee that just quits and leaves, is an
employee that quits and doesn't leave."


Dale Fye said:
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!
 

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