Hi,
I have looked at the example called "Open Parameter queries from code"
from the site http://www.mvps.org/access/queries/qry0003.htm
I made up a test which I though looked pretty close (which I will
paste below)
I have put it on the BeforeUpdate event of a form I am using, but
whenever it is called, I get "Run-time error '13':, Type mismatch
Could anybody give me a suggestion of what I did wrong? Probably a
typo, but I really can't spot it :(
Cheers
Max.
Private Sub Form_BeforeUpdate(Cancel As Integer)
' This is a function which will NOT ALLOW data to be entered if it has
conflicting values
' We have a query which is designed to see if to date/times and a room
passed to it would
' conflict with any of the current bookings. If it does, then it has
to NOT allow this
' entry to be entered into the database. A nice message with as much
information as possible
' should be returned... it "This entry for Room ###xx would conflict
with the booking of XXX"
Dim dbs As Database ' The Current Database
Dim rs As Recordset ' Where the query results will be held
Dim qdQry As QueryDef ' The query which will return the conflicts
Set dbs = CurrentDb()
Set qdQry = dbs.QueryDefs("QryTemp")
' MsgBox ("aborts after this statement")
Set rs = qdQry.OpenRecordset() ' Have rs recieve the query
results
MsgBox ("Before Update test message")
End Sub