Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MS Access 2010 Type Mismatch

Status
Not open for further replies.

Simon656

IS-IT--Management
Apr 20, 2011
4
GB
Hello Everyone,

I'm new here so please go easy with me!

I am getting a MS Access Type Mismatch when clicking an unfiltered link to another form. I know why I get it (it is a text ID to text ID) - (the numeric links all work OK) but I just can not work out the " " and ' '

I would be most grateful if one of you guys could point me in the right direction, thanks in advance.

The code is below:

Private Sub GoToLan_Click()
On Error GoTo Err_GoToLan_Click

Dim rs As Object

Dim lngBookmark As Long

'Close the Springboard
DoCmd.Close acForm, "frmSpringboard", acSaveYes
DoCmd.Close acForm, "frmSpringboard_Docs", acSaveYes
DoCmd.Close acForm, "frmSpringboard_Lan", acSaveYes
DoCmd.Close acForm, "frmSpringboard_Pro", acSaveYes
DoCmd.Close acForm, "frmSpringboard_Ten", acSaveYes
'set a variable to the current record
lngBookmark = Me.[Landlord ID]
'open the new form
DoCmd.OpenForm "frmLandLordManagement"
'take it to the selected record
Set rs = Forms!frmLandLordManagement.RecordsetClone
rs.FindFirst [Landlord ID] = lngBookmark
Forms!frmLandLordManagement.Bookmark = rs.Bookmark

Set rs = Nothing

Exit_GoToLan_Click:
Exit Sub

Err_GoToLan_Click:
MsgBox Err.Description
Resume Exit_GoToLan_Click
End Sub
 
Hello,

Thanks for the quick response, but

rs.FindFirst "[Landlord ID] = " & lngBookmark

this still causes the Type Mismatch.
 
Hi,

Landlord ID id a text data type and can not be null as it is a primary key.

Thanks.
 
If it is text then don't Dim it as Long.
Code:
Dim [red]strBookmark[/red] As [red]String[/red]

'Close the Springboard
DoCmd.Close acForm, "frmSpringboard", acSaveYes
DoCmd.Close acForm, "frmSpringboard_Docs", acSaveYes
DoCmd.Close acForm, "frmSpringboard_Lan", acSaveYes
DoCmd.Close acForm, "frmSpringboard_Pro", acSaveYes
DoCmd.Close acForm, "frmSpringboard_Ten", acSaveYes
'set a variable to the current record
[red]strBookmark[/red] = Me.[Landlord ID]
'open the new form
DoCmd.OpenForm "frmLandLordManagement"
'take it to the selected record
Set rs = Forms!frmLandLordManagement.RecordsetClone
[red]rs.FindFirst "[Landlord ID] = """ & strBookmark & """"[/red]

Duane
Hook'D on Access
MS Access MVP
 
Hi Duane,

Thanks ever so much that has done the trick!

Kind regards
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top