Please Help With Syntax

Evagrius

Registered User.
Local time
Today, 09:21
Joined
Jul 10, 2010
Messages
170
Hi,

I am working on creating a listbox dependant on combobox. I followed an example but I can't get it to work. My listbox is call "ListBuilding" and the combobox is ListCode


Code:
Private Sub ListCode_AfterUpdate()
  Dim strSource     As String
 strSource = "SELECT Building_no " & _
                   "FROM UNIQUE TABLE " & _
                   "WHERE Organization = '" & Me.ListCode & "' ORDER BY Building_no"
Me.ListBuilding.RowSource = strSource
Me.ListBuilding = vbNullString
End Sub
 
Code:
 strSource = "SELECT Building_no " & _
                   "FROM [UNIQUE TABLE] " & _
                   "WHERE Organization = '" & Me.ListCode & "' ORDER BY Building_no"

Notice the [] around your table name. Also bad naming convention adopted, if this is the real name of the table.
 
Thank You DCrake!!

How can I improve the naming convention? Is it because of the " "? Thank you for your help!
 
I suspect that UNIQUE is an Access reserved word, I am sure TABLE is, aditionally avoid using spaces in you names and give them meaningful names.

For Example

TblUniqueTable

QryUniqueTable

FrmUniqueTable
 

Users who are viewing this thread

Back
Top Bottom