I have two forms ADD & VIEW. Each of them have button that will open another
form SERVICE. How can I make to change record source of SERVICE depending on
if it opens from ADD or VIEW?
> I have two forms ADD & VIEW. Each of them have button that will open another
> form SERVICE. How can I make to change record source of SERVICE depending on
> if it opens from ADD or VIEW?
Without my questioning 'WHY', here is How:
Code the Open event of the form "Service":
If Not IsNull(Me.OpenArgs) Then
If Me.OpenArgs = "Add" then
Me.Recordsource = "ABCD"
Else
Me.Recordsource = "XYZ"
End IF
End If
Next code the click event of the button you are using to open this
form:
DoCmd.OpenForm "Service", , , , , , Me.Name

Signature
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
fredg must have more self control than I.
I really must ask why?
It is a very unusual thing to do. It seems you would be using the same
recordsource for both view and add.
IMHO, having two forms, one for view and and one for add is extra work
building it and even more work if you have to maintain it. I use only one
form and use the OpenForm method's arguments to determine how the form will
be used.

Signature
Dave Hargis, Microsoft Access MVP
> I have two forms ADD & VIEW. Each of them have button that will open another
> form SERVICE. How can I make to change record source of SERVICE depending on
> if it opens from ADD or VIEW?