value not valid for field

teel73

Registered User.
Local time
Today, 12:31
Joined
Jun 26, 2007
Messages
205
I have a weird issue. Here goes. [cboSearchby] .. displays "RequestorID" which is an integer and "RequestorName" which is text. [cboFind] displays the values based on what was selected in [cboSearchby]. So requestorID returns all numbers and requestorName returns all text. The problem is, if I select RequestorID first, and then select a value form [cboFind], the value is displayed just fine. But if I want to select RequestorName next and try to select a value from [cboFind] I get an error message that the value is not valid for the field. It only does that if I select the RequestorID first. I can select RequestorName and then select a value, and then select RequestorID next and select a value and it works just fine. I hope I explained my issue good enough. Here's my code below:

Code:
Private Sub cboFind_AfterUpdate()    
    Dim strVal As Variant
    Dim frm As Form
    '
    Set frm = Form_frmSearchRequests_sub
    strVal = [cboFind]

    Select Case cboSearchby.Value
        Case "Request ID"
                    
            frmSearchRequests_sub.Visible = True
            frm.RecordSource = "tblKeyRequests"
            frm.Filter = "[KeyReqID] = " & strVal
            frm.FilterOn = True

        Case "Requestor Name"
            frmSearchRequests_sub.Visible = True
            frm.RecordSource = "tblKeyRequests"
            frm.Filter = "[RequestorName] = '" & strVal & "'"
            frm.FilterOn = True
   End select
 

Users who are viewing this thread

Back
Top Bottom