Hi,
I have a combo box setup which is filled on form load with the names of all the renters in the database, the code for which is as follows...
Dim connection As ADODB.connection
Set connection = New ADODB.connection
connection.Open ("Provider=Microsoft.jet.oledb.4.0;" & "Data Source = h:\NewDatabase.mdb"
Set rs = New ADODB.Recordset
rs.Open "select * from Renter WHERE active = 'ACTIVE'", adoconnection, adOpenDynamic, adLockOptimistic
'Populates combos with database fields
While Not rs.EOF
cboRenter.AddItem rs("Name"
rs.MoveNext
Wend
'Close connection and the recordset
rs.Close
Set rs = Nothing
On form load a error occurs, even though the details are stilled filled into the combo box...
"Syntax error in FROM clause".
I think it may have something to do with the action of the on click event of the combo box. When a user selects a particular renter name from the combo box, all previous dates that this renter has paid rent are, or should be filled into the list box. These details are drawn from the same table. The code for filling the listbox is as follows, where cboRenter is the name of the combo box and newado is the name of the ado setup. Also I cannot set the RecordSource of the newado as again this error appears,
"Syntax Error in From clause"
and I cannot set the DataField of the combo box since this error appears again.
Private Sub cboRenter_Click()
ListDates.Clear
Dim adoconnection As ADODB.connection
Set adoconnection = New ADODB.connection
adoconnection.Open ("Provider=Microsoft.jet.oledb.4.0;" & "Data Source = H:\NewDatabase.mdb"
Set rs = New ADODB.Recordset
Dim Renter As String
Dim intFound As Integer
Let Renter = cboRenter.Text
If Len(Renter) > 0 Then
newado.Refresh
newado.Recordset.MoveFirst
Let intFound = 0
Do While Not newado.Recordset.EOF And intFound < newado.Recordset.RecordCount
If (newado.Recordset.Fields("Name"
.Value) = Renter Then
ListDates.AddItem (newado.Recordset.Fields("Letting_Start"
.Value)
ListDates.ItemData(ListDates.ListCount - 1) = newado.Recordset.Fields("Renter_No"
intFound = intFound + 1
newado.Recordset.MoveNext
Else
newado.Recordset.MoveNext
End If
Loop
Else
MsgBox " Select Renter name First!"
End If
End Sub
Hope this isn't too confusing!
Any ideas?
Thanx!
I have a combo box setup which is filled on form load with the names of all the renters in the database, the code for which is as follows...
Dim connection As ADODB.connection
Set connection = New ADODB.connection
connection.Open ("Provider=Microsoft.jet.oledb.4.0;" & "Data Source = h:\NewDatabase.mdb"

Set rs = New ADODB.Recordset
rs.Open "select * from Renter WHERE active = 'ACTIVE'", adoconnection, adOpenDynamic, adLockOptimistic
'Populates combos with database fields
While Not rs.EOF
cboRenter.AddItem rs("Name"

rs.MoveNext
Wend
'Close connection and the recordset
rs.Close
Set rs = Nothing
On form load a error occurs, even though the details are stilled filled into the combo box...
"Syntax error in FROM clause".
I think it may have something to do with the action of the on click event of the combo box. When a user selects a particular renter name from the combo box, all previous dates that this renter has paid rent are, or should be filled into the list box. These details are drawn from the same table. The code for filling the listbox is as follows, where cboRenter is the name of the combo box and newado is the name of the ado setup. Also I cannot set the RecordSource of the newado as again this error appears,
"Syntax Error in From clause"
and I cannot set the DataField of the combo box since this error appears again.
Private Sub cboRenter_Click()
ListDates.Clear
Dim adoconnection As ADODB.connection
Set adoconnection = New ADODB.connection
adoconnection.Open ("Provider=Microsoft.jet.oledb.4.0;" & "Data Source = H:\NewDatabase.mdb"

Set rs = New ADODB.Recordset
Dim Renter As String
Dim intFound As Integer
Let Renter = cboRenter.Text
If Len(Renter) > 0 Then
newado.Refresh
newado.Recordset.MoveFirst
Let intFound = 0
Do While Not newado.Recordset.EOF And intFound < newado.Recordset.RecordCount
If (newado.Recordset.Fields("Name"

ListDates.AddItem (newado.Recordset.Fields("Letting_Start"

ListDates.ItemData(ListDates.ListCount - 1) = newado.Recordset.Fields("Renter_No"

intFound = intFound + 1
newado.Recordset.MoveNext
Else
newado.Recordset.MoveNext
End If
Loop
Else
MsgBox " Select Renter name First!"
End If
End Sub
Hope this isn't too confusing!
Any ideas?
Thanx!