hardhitter06
Registered User.
- Local time
- Yesterday, 20:37
- Joined
- Dec 21, 2006
- Messages
- 600
Hi All,
I have a database with two tables and two forms.
FormA arrives prior to a Contract. FormB arrives post Contract.
FormA and FormB are actual names of forms in our office.
ContractNo is the FK for both.
On my dashboard, I have a search for FormA. When clicking the command button, a dialog window pops up asking for a Contract No. The user enters the contract number and if that contract No. is in the FormA table it will return a FormA record. (this works)
On this form that opens, I then have a button that is designed to search for a Form B with that same Contract No. I have this code:
What I'm trying to accomplish is if there is a ContractNo from the first search (the FormA search) that matches a record in the FormB table, to display this record on the FormB form I created.
If the FormB doesn't exist for that Contract No, to open a blank input form for FormB.
This isn't working and I'm not sure why. I click the button knowing there is a Form B with that same contract No. but it returns a blank form.
I will attach a zipped file of my DB because this may be confusing.
Thank you.
I have a database with two tables and two forms.
FormA arrives prior to a Contract. FormB arrives post Contract.
FormA and FormB are actual names of forms in our office.
ContractNo is the FK for both.
On my dashboard, I have a search for FormA. When clicking the command button, a dialog window pops up asking for a Contract No. The user enters the contract number and if that contract No. is in the FormA table it will return a FormA record. (this works)
On this form that opens, I then have a button that is designed to search for a Form B with that same Contract No. I have this code:
Code:
Private Sub Command56_Click()
If DCount("*", "FormB", "ContractNo = '" & Me.ContractNo & "'") = 0 Then
If MsgBox("The Contract Number you are searching has no Form B entry." & vbCrLf & vbCrLf & _
"Do you wish to add this record?", vbQuestion + vbYesNo) = vbYes Then _
DoCmd.OpenForm "FormBInput", DataMode:=acFormAdd, OpenArgs:=Me.ContractNo
Else
DoCmd.OpenForm "FormBSearch", WhereCondition:="ContractNo = '" & Me.ContractNo & "'"
End If
End Sub
What I'm trying to accomplish is if there is a ContractNo from the first search (the FormA search) that matches a record in the FormB table, to display this record on the FormB form I created.
If the FormB doesn't exist for that Contract No, to open a blank input form for FormB.
This isn't working and I'm not sure why. I click the button knowing there is a Form B with that same contract No. but it returns a blank form.
I will attach a zipped file of my DB because this may be confusing.
Thank you.