Rabu, 29 Juni 2011

RE: [MS_AccessPros] Data type mismatch in lookup form

Art,
You get a "data type mismatch" issue but don't tell us any of the significant data types :-(
I expect RoomTypeID might be numeric. If so, try:
strWhere = "RoomTypeID = " & Me.RoomTypeID
I would probably just open the form using a Where Condition rather than the recordset stuff.

Duane Hookom
MS Access MVP

To: MS_Access_Professionals@yahoogroups.com
From: dbalorenzini@yahoo.com
Date: Wed, 29 Jun 2011 22:00:41 +0000
Subject: [MS_AccessPros] Data type mismatch in lookup form


I have a main form with a combobox called RoomTypeID. When the user double click on the RoomTypeID it should open a form called frmLkpRoomType which allows the user to add or modify Room Type items. This is code behind the double click event:

Private Sub RoomTypeID_DblClick(Cancel As Integer)
Dim rs As DAO.Recordset
Dim strWhere As String
Const strcTargetForm = "frmLkpRoomType"

'Set up to search for the current Room Type.
If Not IsNull(Me.RoomTypeID) Then
strWhere = "RoomTypeID = """ & Me.RoomTypeID & """"
End If

'Open the editing form.
If Not CurrentProject.AllForms(strcTargetForm).IsLoaded Then
DoCmd.OpenForm strcTargetForm
End If
With Forms(strcTargetForm)

'Save any edits in progress, and make it the active form.
If .Dirty Then .Dirty = False
.SetFocus
If strWhere <> vbNullString Then
'Find the record matching the combo.
Set rs = .RecordsetClone
rs.FindFirst strWhere
If Not rs.NoMatch Then
.Bookmark = rs.Bookmark
End If
Else
'Combo was blank, so go to new record.
RunCommand acCmdRecordsGoToNew
End If
End With
Set rs = Nothing

End Sub

The strWhere is coming back with strWhere="RoomTypeID ="1""

But its erroring out on the rs.FindFirst strWhere with a Data Type Mismatch.

This snippet I found on Allen Browne site.

The form frmLkpRoomType contains two fields called RoomTypeID and RoomTypeName

Any Ideas?

Thanks,
Art Lorenzini


[Non-text portions of this message have been removed]

------------------------------------

Yahoo! Groups Links

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/MS_Access_Professionals/

<*> Your email settings:
Individual Email | Traditional

<*> To change settings online go to:
http://groups.yahoo.com/group/MS_Access_Professionals/join
(Yahoo! ID required)

<*> To change settings via email:
MS_Access_Professionals-digest@yahoogroups.com
MS_Access_Professionals-fullfeatured@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
MS_Access_Professionals-unsubscribe@yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/

Tidak ada komentar:

Posting Komentar