Combo not working

chrisguk

Registered User.
Local time
Today, 12:52
Joined
Mar 9, 2011
Messages
148
Hi,

I create this combo box but I keep getting error 3464 type mismatch. My code is below and would be grateful if anyone is able to point out the error.

Oh by the way and I am not sure if it makes a difference. I do have a subform on the form too.

Here is the lookup:

Row Source = Table/Query
Code:
SELECT [tblsites].[sitesid], [sitesdescr] AS Site FROM tblsites ORDER BY [tblsites].[sitesdescr];

After Update Event:
Code:
Option Compare Database
Option Explicit
Private Sub cboFindRecord_AfterUpdate()
   ' Find the record that matches the control.
   On Error GoTo ProcError
   Dim rs As Object
   Set rs = Me.Recordset.Clone
   rs.FindFirst "[sitesid] = '" & Me![cboFindRecord] & "'"
   If Not rs.EOF Then Me.Bookmark = rs.Bookmark
ExitProc:
   Exit Sub
ProcError:
   MsgBox "Error: " & err.Number & ". " & err.Description
   Resume ExitProc

End Sub
 
My guess is that siteid is defined as a Number Datatype field and the line

rs.FindFirst "[sitesid] = '" & Me![cboFindRecord] & "'"

is the syntax for a Text field.

Replace the line

rs.FindFirst "[sitesid] = '" & Me![cboFindRecord] & "'"

with

rs.FindFirst "[sitesid] = " & Me![cboFindRecord]

Linq ;0)>
 
Hi Ling,

Your solution was perfect and I dont know why I didnt spot it.

Maybe you are to help me with this other issue too.

I have been trying to get this click activity to work but I keep getting errors. My code is below:

Code:
Private Sub view_closed_queries_Click()
Dim qrycounter As String
Dim status As String
status = DLookup("Log_status", "tbllog", "Criteria= 'CLOSED'")
qrycounter = DCount("[Logid]", "tbllog", "[tbllog].[sitesid] = " & [Forms]![frmsites]![sitesid] & " ")
    
    If qrycounter < 0 Then
     MsgBox "There are no Closed Queries on this Site", vbInformation = vbOKOnly, "No Query"
Else
     If status = "CLOSED" Then
           DoCmd.OutputTo acOutputQuery, "qryview_closed_queries", acFormatXLS, "All_Queries.xls", True
     Else
            MsgBox "There are no Closed Queries on this Site", vbInformation = vbOKOnly, "No Query"
     End If
End If
    End Sub
 

Users who are viewing this thread

Back
Top Bottom