change record source

  • Thread starter Thread starter Ira
  • Start date Start date
I

Ira

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
 
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.
 
Back
Top