R
Rick Kunkel
Heya All,
I have a single form, and I want it to be usable with several queries.
It seems that people generally change the RecordSource property of the
form, and that's what I'm currently doing, with two buttons, like
this:
Private Sub btnFindContact_Click()
strfind = inputbox("Input Part of Contact Name")
strSQL = "select * from orgs where orgid in (select orgid from
contacts where ContactName like '%" & strfind & "%')"
DoCmd.OpenForm ("Orgs")
Forms![Orgs].RecordSource = strSQL
End Sub
Private Sub btnFindOrg_Click()
strfind = inputbox("Input Part of Organization Name")
strSQL = "select * from orgs where OrgName like '%" & strfind & "%'"
DoCmd.OpenForm ("Orgs")
Forms![Orgs].RecordSource = strSQL
End Sub
Essentially, the form needs to use one of the following two queries:
1. select * from Orgs where OrgName like '%{VARIABLE}%'
2. select * from Orgs where OrgID in (select orgid from contacts
where ContactName like '%{VARIABLE}%'
Is changing the RecordSource the best (only?) way to do this? Or are
there other ways?
Does the way I'm doing it look fine?
Thanks,
Rick Kunkel
I have a single form, and I want it to be usable with several queries.
It seems that people generally change the RecordSource property of the
form, and that's what I'm currently doing, with two buttons, like
this:
Private Sub btnFindContact_Click()
strfind = inputbox("Input Part of Contact Name")
strSQL = "select * from orgs where orgid in (select orgid from
contacts where ContactName like '%" & strfind & "%')"
DoCmd.OpenForm ("Orgs")
Forms![Orgs].RecordSource = strSQL
End Sub
Private Sub btnFindOrg_Click()
strfind = inputbox("Input Part of Organization Name")
strSQL = "select * from orgs where OrgName like '%" & strfind & "%'"
DoCmd.OpenForm ("Orgs")
Forms![Orgs].RecordSource = strSQL
End Sub
Essentially, the form needs to use one of the following two queries:
1. select * from Orgs where OrgName like '%{VARIABLE}%'
2. select * from Orgs where OrgID in (select orgid from contacts
where ContactName like '%{VARIABLE}%'
Is changing the RecordSource the best (only?) way to do this? Or are
there other ways?
Does the way I'm doing it look fine?
Thanks,
Rick Kunkel