Hi
I'm trying to make a form in wich, if you receive an article, you put it in a certain location. If there is already an article on that location, the combobox in wich you choose the location the combobox should color red. It doesn't mean the article can't be placed on that location but it should be checked.
The combobox is filled with data from a tabel 'Locations' and the selected option should be checked in a query 'qryStock'.
Code:
Private Sub cboLocation_AfterUpdate()
Dim rs0 As ADODB.Recordset
'Set rs0 = CurrentDb.OpenRecordset("SELECT ArtikcleNr FROM qryStock WHERE LocationNr = '" & Me.cboLocatie.Text & "'") <-- Error 13 occurs here
'rs0.Open "SELECT ArticleNr FROM qryStock WHERE LocationNr = '" & Me.cboLocation & "'", CurrentProject.OpenConnection, adOpenStatic, adLockReadOnly <-- Error 91 occurs here
If rs0.RecordCount > 0 Then
Me.cboLocation.BackColor = 255
Me.cboLocation.ForeColor = 16777215
Else
Me.cboLocation.BackColor = 16777215
Me.cboLocation.ForeColor = 0
End If
End Sub
This is the code I have so far. I have tried 2 different options, both give an error.
The first option gives the error 13: Type mismatch.
The second option gives the error 91: Object variable or With block not set.
I really hope you guys can help.
With kind regards