João serras-pereira
asked on
type mismatch on rst.findfirst
Hi -
On my app I need to validate it a certain record exists, before trying to insert a new one. The the existence is determined by a rst.findferst on the rst (a query), that combines two columns.
my code is:
Dim tblSelecaoDetail_r As DAO.Recordset
Dim qryMMRfilterNew_rst As DAO.Recordset
Dim tblSelecaoDetail_rst As DAO.Recordset
Dim qrySelecaoExistencias_rst As DAO.Recordset
Dim strLocateSelected As String
Dim lngNumRecords As Long
Dim strX As String
Set BddPlus = CurrentDb
Set qryMMRfilterNew_rst = BddPlus.OpenRecordset("qry MMRfilterN ew", dbOpenDynaset)
Set tblSelecaoDetail_rst = BddPlus.OpenRecordset("tbl SelecaoDet ail", dbOpenDynaset)
Set qrySelecaoExistencias_rst = BddPlus.OpenRecordset("qry SelecaoExi stencias", dbOpenDynaset)
...
Do While Not qryMMRfilterNew_rst.EOF
' acrescentar os registos seleccionados de qryMMRfilterNew à selecção escolhida
' mas... se já existe... não inserir!
strLocateSelected = "existe = '" & Me.frmfld_refSelecao & qryMMRfilterNew_rst!CodMil itante & "'"
qrySelecaoExistencias_rst. FindFirst strLocateSelected
If qrySelecaoExistencias_rst. NoMatch = "" Then
tblSelecaoDetail_rst.AddNe w
tblSelecaoDetail_rst!CodMi litante = qryMMRfilterNew_rst!CodMil itante
tblSelecaoDetail_rst!refSe lecaoMaste r = Me.frmfld_refSelecao
tblSelecaoDetail_rst.Updat e
lngNumRecords = lngNumRecords + 1
End If
qryMMRfilterNew_rst.MoveNe xt
Loop
but I am getting, on the rst.nomatch statement tye "type mismatch" error
the rst looks OK as well as the search field...
can anyone help?
On my app I need to validate it a certain record exists, before trying to insert a new one. The the existence is determined by a rst.findferst on the rst (a query), that combines two columns.
my code is:
Dim tblSelecaoDetail_r As DAO.Recordset
Dim qryMMRfilterNew_rst As DAO.Recordset
Dim tblSelecaoDetail_rst As DAO.Recordset
Dim qrySelecaoExistencias_rst As DAO.Recordset
Dim strLocateSelected As String
Dim lngNumRecords As Long
Dim strX As String
Set BddPlus = CurrentDb
Set qryMMRfilterNew_rst = BddPlus.OpenRecordset("qry
Set tblSelecaoDetail_rst = BddPlus.OpenRecordset("tbl
Set qrySelecaoExistencias_rst = BddPlus.OpenRecordset("qry
...
Do While Not qryMMRfilterNew_rst.EOF
' acrescentar os registos seleccionados de qryMMRfilterNew à selecção escolhida
' mas... se já existe... não inserir!
strLocateSelected = "existe = '" & Me.frmfld_refSelecao & qryMMRfilterNew_rst!CodMil
qrySelecaoExistencias_rst.
If qrySelecaoExistencias_rst.
tblSelecaoDetail_rst.AddNe
tblSelecaoDetail_rst!CodMi
tblSelecaoDetail_rst!refSe
tblSelecaoDetail_rst.Updat
lngNumRecords = lngNumRecords + 1
End If
qryMMRfilterNew_rst.MoveNe
Loop
but I am getting, on the rst.nomatch statement tye "type mismatch" error
the rst looks OK as well as the search field...
can anyone help?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
now I am posting a related quesiton as it is always returning TRUE but the record is there so it should return FALSE...