Please help, simple code cannot figure out why is not working

marvin67

Registered User.
Local time
Today, 13:28
Joined
Apr 8, 2004
Messages
11
Hello,,

I have a code below, for some reason if i want to add the line "Order by" the code doesn't work. I'm not sure if it a syntax error. Any help would be highly appreciated

Here is the code

Private Sub CustomerList_AfterUpdate()

With Me.ContactList
.RowSource = _
"Select ID, CustomerID, Firstname, Lastname, Phone, Email From tblcustomercontact " & _
"Where CustomerID = " & Me.CustomerList
' "Order by ID Desc"
.ColumnCount = 6
.ColumnWidths = ".31in;.5in; 1.1 in; 1 in; 1 in;1 in;"
.ColumnHeads = True
.Requery
End With

End Sub

I have disabled the order line above and my listbox will populate, but enabling it won't.
 
You need the continuation to add the line.

BTW A better layout for this is:
Code:
.RowSource = "SELECT ID, CustomerID, Firstname, Lastname, Phone, Email" _
           & " FROM tblcustomercontact" _
           & " WHERE CustomerID = " & Me.CustomerList _
           & " ORDER BY ID Desc"
 
Thank you very much for your help. I did add continuation line but i think i miss spaces and i do not understand much this continuation thing. I followed your layout including all the spaces and it work.

I have a limited knowledge about coding since i learn this stuff through self studies. I really appreciate your help.

Thanks
 
Continuation consists of two characters <space underscore>

BTW Continuation is limited to 22 consecutive lines.
 

Users who are viewing this thread

Back
Top Bottom