Rabu, 12 Oktober 2011

RE: [MS_AccessPros] Type mismatch that I can't figure out

 

Connie-

Why do you have extra parens in the third argument? The word " And " is not
being included in the filter string. Try:

'If ParcelNbr in the same County exists in the HomeInfo table
If Not IsNull(DLookup("ParcelNbr", "HomeInfo", _
"ParcelNbr = """ & Me.ParcelNbr & """ And CountyID = " & Me.CountyID)) Then
MsgBox "This Parcel Nbr is already in the database." & vbNewLine & _
"Use Ctrl F to find the property."
Me.Undo
Me.ParcelNbr.SetFocus
End If

Note also that I changed GoToControl to a more direct SetFocus.

John Viescas, author
Microsoft Office Access 2010 Inside Out
Microsoft Office Access 2007 Inside Out
Building Microsoft Access Applications
Microsoft Office Access 2003 Inside Out
SQL Queries for Mere Mortals
http://www.viescas.com/
(Paris, France)

-----Original Message-----
From: MS_Access_Professionals@yahoogroups.com
[mailto:MS_Access_Professionals@yahoogroups.com] On Behalf Of mrsgoudge
Sent: Wednesday, October 12, 2011 7:03 PM
To: MS_Access_Professionals@yahoogroups.com
Subject: [MS_AccessPros] Type mismatch that I can't figure out

Good morning/whatever it is where you are!

I'm getting Type mismatch error.

The code:
-HomeInfo form
-ParcelNbr textbox
-AfterUpdate event
-Goal of the code is to check to see if there's another entry in the HomeInfo
table with the same County and ParcelNbr and if so give a message saying that
this property is already in the database.

ParcelNbr is text field
ContactID is a long integer in both the HomeInfo table and the County_List
table.

When I hover Me.ParcelNbr = "12-0045-000" and Me.CountyID.Column(0) = "1" If I
change it to Me.CountyID then when I hover Me.CountyID = 1. Either way I get
the message.

Many thanks!
Connie

'If ParcelNbr in the same County exists in the HomeInfo table
If Not IsNull(DLookup("ParcelNbr", "HomeInfo", ("ParcelNbr = """ & Me.ParcelNbr
& """") And ("CountyID = " & Me.CountyID.Column(0)))) Then
MsgBox "This Parcel Nbr is already in the database." & vbNewLine & _
"Use Ctrl F to find the property."
Me.Undo
DoCmd.GoToControl "ParcelNbr"
End If

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

Yahoo! Groups Links

__._,_.___
Recent Activity:
MARKETPLACE

Stay on top of your group activity without leaving the page you're on - Get the Yahoo! Toolbar now.

.

__,_._,___

Tidak ada komentar:

Posting Komentar