G
Guest
Access 03 in WinXP
I am trying to set the recordsource for a form to a recordset which is
defined by which company database I am currently in. In defining the SQL
statement, I then need to define the ControlSource property for two text
boxes to the two fields in the SQL statement, which unfortunately are
different based upon the company database.
Dim MySQL, MyCompany as String
' MyCompany is defined in a lookup
If MyCompany = "ABC" Then
MySQL = "Select Address1, Address2 From TempABC;"
Forms!frmVerifyInfo.RecordSource = MySQL
Me.txtVerify1.ControlSource = MySQL.Address1
Me.txtVerify2.ControlSource = MySQL.Address2
ElseIf MyCompany = "XYZ" Then
MySQL = "Select Company1, Company2 From TempABC;"
Forms!frmVerifyInfo.RecordSource = MySQL
Me.txtVerify1.ControlSource = MySQL.Company1
Me.txtVerify2.ControlSource = MySQL.Company2
End If
This is producing the error on the first ControlSource definition with the
"MySQL." giving the error message "Invalid Qualifier". If I change the
definition from MySQL.Address1 to [Address1], and so on, then the form opens
but all records are have the data of the first record.
I initially tried using rs as Recordset, defining my recordset with the SQL
statement, and then setting the RecordSource to the rs recordset, but this
gave me an error of Type Mismatch.
Any suggestions on how to accomplish what I am trying to do will be truly
appreciated.
Thanks!
I am trying to set the recordsource for a form to a recordset which is
defined by which company database I am currently in. In defining the SQL
statement, I then need to define the ControlSource property for two text
boxes to the two fields in the SQL statement, which unfortunately are
different based upon the company database.
Dim MySQL, MyCompany as String
' MyCompany is defined in a lookup
If MyCompany = "ABC" Then
MySQL = "Select Address1, Address2 From TempABC;"
Forms!frmVerifyInfo.RecordSource = MySQL
Me.txtVerify1.ControlSource = MySQL.Address1
Me.txtVerify2.ControlSource = MySQL.Address2
ElseIf MyCompany = "XYZ" Then
MySQL = "Select Company1, Company2 From TempABC;"
Forms!frmVerifyInfo.RecordSource = MySQL
Me.txtVerify1.ControlSource = MySQL.Company1
Me.txtVerify2.ControlSource = MySQL.Company2
End If
This is producing the error on the first ControlSource definition with the
"MySQL." giving the error message "Invalid Qualifier". If I change the
definition from MySQL.Address1 to [Address1], and so on, then the form opens
but all records are have the data of the first record.
I initially tried using rs as Recordset, defining my recordset with the SQL
statement, and then setting the RecordSource to the rs recordset, but this
gave me an error of Type Mismatch.
Any suggestions on how to accomplish what I am trying to do will be truly
appreciated.
Thanks!