Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Two cmd buttons call same form, different record set?

Status
Not open for further replies.

CarpalT

MIS
Jan 17, 2003
178
0
0
US
I have a table with two kinds of records. A form that allows the user to do some things. A command button calls the form, and the form's data source is a query (qryFindCredits) that selects record type "CM". Now we want to view record type "DED" under certain circumstances, by clicking a second button. Can I re-use the same form and call it from either button by specifying the second query (qryFindDeductions) as a data source when appropriate?

Buttons would be labeled "View Credit Memos" & "View Deductions".
Or maybe there is a better way?
Thanks much. [pc]

The world is full of good people.
 
Hi

If the form suits the display of both record types (ie all the controls and labels are identical) then all you need is one button on the form to change its record source:

Code:
Sub Command1_Click

  If Me.RecordSource="qryFindCredits" Then
    Me.RecordSource="qryFindDeductions"
    Me.Command1.Caption="View Credit Memos"
  Else
    Me.RecordSource="qryFindCredits"
    Me.Command1.Caption="View Deductions"
  End If

End Sub
You can use two buttons and just disable the button for the record source you are viewing etc as each is clicked. You can also change controls and labels on the form when the button is clicked if you require.

Hope this helps.

Steve
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top