David,
I'm not sure if I have seen an answer to your post. The only time you should need to use code to update the SQL property of your Row Source is when it dynamically needs to change like cascading combo/list boxes. These special case typically have "trigger" events like the After Update event of one combo box should limit the selections in another combo box.
To set the initial Row Source I would do this in the On Open event of the form.
One tool I use is http://www.dpriver.com/pp/sqlformat.htm
It will take something like:
FROM CarModels
WHERE ModelMake = "Ford"
and convert it to VB:
varname1 = varname1 & "SELECT Model " & vbCrLf
varname1 = varname1 & "FROM CarModels " & vbCrLf
varname1 = varname1 & "WHERE ModelMake = ""Ford"""
Sent: Monday, August 7, 2017 6:41 PM
To: MS_Access_Professionals@yahoogroups.com
Subject: [MS_AccessPros] Using SQL in the Row Source
this is likely a simpleton question, but I need to ask since I am not certain.
If I have an unbound form with a parent and child list boxes, a form style I find myself using a lot. For my education I want to write SQL code for the row souces of the list boxes. I have always used the row source of the list box properties and used the query builder to build the queries that serve as the row source.
I'd like to practice writing the SQL code using the strSQL = strSQL & "..." process to build the list boxes. Where do I put the SQL code? Do I build the SQL statements in the Form_Open event? and then just assign the SQL to the list box control?
me.lstOne.RowSource = strSQL1
me.lstTwo.RowSource = strSQL2
Posted by: Duane Hookom <duanehookom@hotmail.com>
Reply via web post | • | Reply to sender | • | Reply to group | • | Start a New Topic | • | Messages in this topic (2) |
Tidak ada komentar:
Posting Komentar