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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Record Source Question 1

Status
Not open for further replies.

Choobok

MIS
Jan 25, 2007
2
US
Would any of you gurus know how to change the record source of an Access dbase form on the fly? I have a standard form which is used to display records of 3 different types of software applications (Desktop, EA, MSDN). I would like to have 3 command buttons on the form each one programmed to change the record source of the form to the corresponding query in order to populate the form with the appropriate records Desktop, EA or MSDN applications. Can this be done or do I have to have separate forms for each query record source?
 
Hi Choobok,
Write on-click event for each command button something like this...........

Dim Frm as Form
Dim sql as string

sql= "Relevant query sql goes here"
Set Frm = Forms("YourFormName")
Frm.recordsource = sql
Frm.refresh
Set Frm=nothing

 
Thanks a lot tekkyun. I was able to use the code you provided. I had some minor glitches but when I modified it a little it worked perfectly. This is what I changed:

Dim Frm As Form
'Dim sql As String
'sql = test_ea_apps
Set Frm = Forms(Test)
Frm.RecordSource = "qry-MSDN Applications"
'Frm.Refresh
'Set Frm = Nothing

I didn't seem to need the other lines of code. So I blocked them out. Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top