Graham,
Thanks. Works great. Sorry I didn't get back to you
sooner, but I've been under the weather.
I have another problem. I have 1 form that is supposed
to display data from 2 records (tblCustomer & tblJobSite).
The problem is that on some records the RecordSource
( an SQL query ) works fine and sometimes it dosen't
work at all and gives me a form with no data in the
form fields. (Yes there is data in the tables.)
If I open frmJobSiteInformation by itself (not through
the frmEstimate, then all the records are displayed.
Data Entry on this form is set to No because this is
not the place where data entry or corrections
need to be made. I have both a frmCustomer goes to
tblCustomer and frmJobSite goes to tblJobSite this
is the place to enter the initial information. There is
a CustomerID field in both tblCustomer and tblJobSite.
There is also the JobID field in both tblJobSite and
tblEstimate.
The form is frmJobSiteInformation. the SQL query was
actually built by the forms Wizard.
SELECT DISTINCTROW tblJobSite.CustomerID, tblJobSite.JobID,
tblJobSite.ContactName, tblJobSite.JobSiteAddress,
tblJobSite.JobSiteCity, tblJobSite.JobSiteState,
tblJobSite.JobSitePhone, tblCustomer.CompanyName,
tblCustomer.CustContactName, tblCustomer.CustomerAddress,
tblCustomer.CustomerCity, tblCustomer.CustomerState,
tblCustomer.CustomerZipCode, tblCustomer.CustomerPhone
FROM tblCustomer INNER JOIN tblJobSite ON
tblCustomer.CustomerID = tblJobSite.CustomerID;
Now there is a command button in the frmEstimate
(cmdJobSiteInformation) that opens the frmJobSiteInformation
matching the field JobID in both the frmEstimate and
the frmJobSiteInformation.
Private Sub cmdJobSiteInformation_Click()
On Error GoTo Err_cmdJobSiteInformation_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmJobSiteInformation"
stLinkCriteria = "[JobID]=" & "'" & Me![txtJobID] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_cmdJobSiteInformation_Click:
Exit Sub
Err_cmdJobSiteInformation_Click:
MsgBox Err.Description
Resume Exit_cmdJobSiteInformation_Click
End Sub
The frmJobSiteInformation is displayed to the screen
and it has a command button (cmdPrintEstimate)
after the Estimate is printed the user returns to the
frmEstimate and can exit back to the Switchboard
or enter another estimate.
I can't figure it out. Is there a better way that I
should be using? Please help, I'm at a dead end.
Thanks,
LadyAmethyst
Graham Mandeno said:
Hi again
I suggest you pass the name of the calling form to frmDeposit via the
OpenArgs property:
DoCmd.OpenForm strDocName, , , strLinkCriteria, OpenArgs:=Me.Name
Then, in Form_Load:
Dim frmCallingForm as Form
If Not IsNull(Me.OpenArgs) then
Set frmCallingForm = Forms(Me.OpenArgs)
You can then refer to controls on the calling form as, for example:
frmCallingForm![Division]
instead of:
Forms![frmEstimate]![Division]
Where the control names are different, you can check the form name first:
If frmCallingForm.Name = "frmEstimate" Then
txtEstimateTotalCost = frmCallingForm![EstimateTotalCost]
Else
txtEstimateTotalCost = frmCallingForm![RevEstimateTotalCost]
End If
--
Good Luck!
Graham Mandeno [Access MVP]
Auckland, New Zealand