A
Amour
I have one form were I create meetings, than another one were the individual
is inputted (all works great - this is not the problem). I am trying to open
a form(Travel) from that form by clicking on a button (This I already have
and that part works). I want the newly opened form (Travel) to automatically
populate a few fields (that you can not see on the form) that are the primary
fields. example: [field1] = Me.[field1] and [field2] = Me.[field2].
Now if the record already exist then I want it to populate the form.
So far I have this:
Private Sub btnTravel_Click()
On Error GoTo Err_btnTravel_Click
Dim DocName As String
DocName = "frmTravel"
DoCmd.OpenForm DocName, , , "[Field1]='" & Me.[Field1] & "' AND
[Field2]='" & Me.[Field2] & "'"
Exit_btnTravel_Click:
Exit Sub
Err_btnTravel_Click:
MsgBox Error$
Resume Exit_btnTravel_Click
End Sub
The way it is working right now is:
1.) If it exist in the table then it comes up
2.) but if it does not exist then the form is blank
What I want is for it to come up both ways:
1.) If it exist in the table then it comes up
2.) but if it does not exist then the form is to be populated by the other
forms putting both fields on the new form so I can add a record.
Please help.
Thank you for any help.
is inputted (all works great - this is not the problem). I am trying to open
a form(Travel) from that form by clicking on a button (This I already have
and that part works). I want the newly opened form (Travel) to automatically
populate a few fields (that you can not see on the form) that are the primary
fields. example: [field1] = Me.[field1] and [field2] = Me.[field2].
Now if the record already exist then I want it to populate the form.
So far I have this:
Private Sub btnTravel_Click()
On Error GoTo Err_btnTravel_Click
Dim DocName As String
DocName = "frmTravel"
DoCmd.OpenForm DocName, , , "[Field1]='" & Me.[Field1] & "' AND
[Field2]='" & Me.[Field2] & "'"
Exit_btnTravel_Click:
Exit Sub
Err_btnTravel_Click:
MsgBox Error$
Resume Exit_btnTravel_Click
End Sub
The way it is working right now is:
1.) If it exist in the table then it comes up
2.) but if it does not exist then the form is blank
What I want is for it to come up both ways:
1.) If it exist in the table then it comes up
2.) but if it does not exist then the form is to be populated by the other
forms putting both fields on the new form so I can add a record.
Please help.
Thank you for any help.