Run-time Error '2471':

JohnLee

Registered User.
Local time
, 22:10
Joined
Mar 8, 2007
Messages
692
Hi can anyone help me with this Run-time Error!

I don't understand what it means here's full message:

Run-time Error '2471':

The expresssion you entered as a query parameter produced this error:
'The object doesn't contain the Automation Object 'B1322N1GB,"

The following is the code used before the above error message kicks in:

Code:
Dim ModelNo             'Declare the ModelNo variable

Dim Char1               'Declare the Char1 variable
Dim Char2               'Declare the Char2 variable
Dim Char3               'Declare the Char3 variable
Dim Char4               'Declare the Char4 variable
Dim Char5               'Declare the Char5 variable
Dim Char6               'Declare the Char6 variable
Dim Char7               'Declare the Char7 variable
Dim Char8               'Declare the Char8 variable
Dim Char9               'Declare the Char9 variable

'Assign the value of the txtModelNo field to the ModelNo variable
ModelNo = Me![txtModelNo].Value

Char1 = Left(ModelNo, 1)
Char2 = Mid(ModelNo, 2, 1)
Char3 = Mid(ModelNo, 3, 1)
Char4 = Mid(ModelNo, 4, 1)
Char5 = Mid(ModelNo, 5, 1)
Char6 = Mid(ModelNo, 6, 1)
Char7 = Mid(ModelNo, 7, 1)
Char8 = Mid(ModelNo, 8, 1)
Char9 = Right(ModelNo, 1)

If Char1 = "B" Or Char1 = "D" Or Char1 = "H" Or Char1 = "N" Or Char1 = "S" Then
    
    If Char1 = "B" Then
        Char1 = "8"
    ElseIf Char1 = "D" Then
            Char1 = "O"
    ElseIf Char1 = "H" Then
        Char1 = "N"
    ElseIf Char1 = "N" Then
        Char1 = "H"
    ElseIf Char1 = "S" Then
        Char1 = "5"
    End If
End If

ModelNo = Char1 & Char2 & Char3 & Char4 & Char5 & Char6 & Char7 & Char8 & Char9

If DCount("[strModelNo]", "[tblAJL_Test]", "[strModelNo]=" & Me![txtModelNo]) = 0 Then

	'Create the new record and move to the next record
    	DoCmd.GoToRecord , "frmAJL_Test", acNext, 1
   	 'Assign the new model number to the txtModelNo field
   	 Me![txtModelNo].Value = ModelNo
    	Me![txtAppCode].Value = AppCode
    	Me![txtModelNo2].Value = ModelNo2

    	Else 'If already exists

   	'Go to the next record
    	DoCmd.GoToRecord , "frmAJL_Test", acNext, 1
   	 'Assign the new model number to the txtModelNo field
  	Me![txtModelNo].Value = ModelNo
    	Me![txtAppCode].Value = AppCode
    	Me![txtModelNo2].Value = ModelNo2
   
End If

[END CODE]

The "B1322N1GB" of the error message is obtained from the txtModelNo object on the form which is the strModelNo field in the underlaying table.

I am trying to create a variation of the model number, but want check weather it exists before it is created and if it already exist, then don't create it but create another variation and do the same process.

Any assistance would be appreciated.

John
 
Your Criteria in the DCount function is comparing a String, therefore the criteria must be wrapped in quotes or DCount looks for a variable with the string name you passed:

DCount("[strModelNo]", "[tblAJL_Test]", "[strModelNo]='" & Me![txtModelNo] & "'")
 
Your Criteria in the DCount function is comparing a String, therefore the criteria must be wrapped in quotes or DCount looks for a variable with the string name you passed:

DCount("[strModelNo]", "[tblAJL_Test]", "[strModelNo]='" & Me![txtModelNo] & "'")

Hi Bodisathva,

Thanks very much for your help, that solved my problem indeed.

Much appreciated.

John:)
 
Hi,

I have a similar problem with the RT error.

I have tried the solution posted but still get it.

Here is the function:
Public Function getGroup(x_stn0 As Long, x_groupType As String)

Dim v_groupval As String
Dim v_classgroup, v_pracgroup, v_tutgroup As String
v_classgroup = "C"
v_pracgroup = "P"
v_tutgroup = "T"

Dim v_grouptype As Integer

If x_groupType = "C" Then
v_grouptype = 1
ElseIf x_groupType = "T" Then
v_grouptype = 2
ElseIf x_groupType = "P" Then
v_grouptype = 3
Else: v_grouptype = 99
End If

Select Case v_grouptype
Case 1
v_groupval = DLookup("[IAHCLASSGROUP]", "IAHSUB_SORTED", ("[IAHSTNO] = " & x_stn0 & " and " & x_groupType & " = '" & v_classgroup & "'"))
Case 2
v_groupval = DLookup("[IAHTUTGROUP]", "IAHSUB_SORTED", ("[IAHSTNO] = " & x_stn0 & " and " & x_groupType & " = '" & v_tutgroup & "'"))
Case 3
v_groupval = DLookup("[IAHPRACGROUP]", "IAHSUB_SORTED", ("[IAHSTNO] = " & x_stn0 & " and " & x_groupType & " = '" & v_pracgroup & "'"))
Case Else
Debug.Print "Not a valid Group Type"
End Select
getGroup = v_grouptype

End Function

The message that accompanies this error is:
The expression you entered as a query parameter produced this error: 'C'.

I am testing this function with the following:
Function toets_class1()
Dim t_groupval As String
t_groupval = getGroup(9510101, "C")
End Function

Normally the "C" will be selected from a database and passed to the getGroup function.

Thank you in advance.

Phlip
 
dim strsql as string

strsql="[IAHSTNO] = " & x_stn0 & " and " & x_groupType & " = '" & v_classgroup & "'")
debug.print strsql
 
Hi,

Thanks for the response.

I found the error - I forgot to also include the x_groupType in single quotes.:p

Regards,

Phlip
 

Users who are viewing this thread

Back
Top Bottom