Filtering with command buttons and RecordSource

  • Thread starter Thread starter Christopher Glaeser
  • Start date Start date
C

Christopher Glaeser

Command button "Open" sets Me.RecordSource to "qryWorkOrdersOpen", and
Command button "All" sets Me.RecordSource to "tblWordOrders". Users can
view Open/All workorders by toggling on these two command buttons. Couple
quick questions ...

1. Me.RecordSource apparently stays set to the last command, even after the
form is closed and then reopened. I would have guessed the form would open
with the source specified on the form design. If I want to change the
behavior, where is the recommended place to put the code to open the form
with a default RecordSource?

2. Regarding the design of these two command buttons that can change the
record source back and forth, should the last-selected comman button be
greyed out to make it clear the command has already been selected? What is
the code to accomplish this?

Best,
Christopher
 
Command button "Open" sets Me.RecordSource to "qryWorkOrdersOpen", and
Command button "All" sets Me.RecordSource to "tblWordOrders". Users can
view Open/All workorders by toggling on these two command buttons. Couple
quick questions ...

1. Me.RecordSource apparently stays set to the last command, even after the
form is closed and then reopened. I would have guessed the form would open
with the source specified on the form design. If I want to change the
behavior, where is the recommended place to put the code to open the form
with a default RecordSource?

do you use: docmd.close acform, me.name, acsaveyes
when you close the form?
Normally the Form has the last recordsource when saved

2. Regarding the design of these two command buttons that can change the
record source back and forth, should the last-selected comman button be
greyed out to make it clear the command has already been selected? What is
the code to accomplish this?

onClick-event :
me.Control.enabled = false
me.otherControl.enabled=true

in the onOpen you write the same to have a Default
BTW: you could do the same with me.recordsource
If you expect an answer to a personal mail, add the word "manfred" to the first 10 lines in the message
MW
 
Back
Top