Hi,
I have the following problem:
I have a button in a form that suppose to open another form, coping a number and pasting in the new form field.
It works perfectly, but only one time. If the new form have data on it, it doesnt work. The error is: Data type mismatch in criteria expression
Here is the code of the button:
Code:
Private Sub AbrirDadosdosCondutores_Click()
On Error GoTo Err_AbrirDadosdosCondutores_Click
Dim stDocName As String
Dim strCriteria As String
strCriteria = "[N do Seguro] = """ & Me.[N do Seguro] & """"
DoCmd.OpenForm "Dados dos Condutores", _
WhereCondition:=strCriteria, _
WindowMode:=acDialog, _
OpenArgs:=(Me.[N do Seguro])
Exit_AbrirDadosdosCondutores_Click:
Exit Sub
Err_AbrirDadosdosCondutores_Click:
MsgBox Err.Description
Resume Exit_AbrirDadosdosCondutores_Click
End Sub
I think the code should add something that says: open in a new record. Probably is trying to open the form, and the form opens showing the first record. As Access is unable to change the primary key, since it has a relationship with other tables, so I get the error.
How can I make the button open a form in a new record?