Try this
1. Dim R As Recordset
2. Dim SqlText As String
3. SqlText = "Select * From Product Where trknum=" & me.trknum2 & ";"
4. If CurrentDb.OpenRecordset(SqlText).RecordCount > 0 Then
5. MsgBox "Record Exists"
6. Else
7. MsgBox "Record Not Found"
8. End If
HTH, Igor
>The following code works on a form that I created. However, I want to replace the '5' in line 3 with the value from a textbox on the form. The name of the textbox is trknum2. When I try to replace '5' with form![trknum2], or if I type:
>
>Dim mvar as Long
>mvar = form![trknum2}.value
>
>and replace the '5' with mvar
>
> I get an error message saying it's looking for another argument. I am assuming that this can be done and that the error has something to do with trknum being dimmed as Long but I am not sure. I would really appreciate any help.
>
>
1. Dim R As Recordset
>2. Dim SqlText As String
>
>3. SqlText = "Select * From Product Where trknum = 5;"
>4. If CurrentDb.OpenRecordset(SqlText).RecordCount Then
>5. MsgBox "Record Exists"
>6. Else
>7. MsgBox "Record Not Found"
>8. End If
Igor Gelin
Database Developer