473,776 Members | 1,650 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

syntax error? parameter querydefs



Set qd = CurrentDb.Query Defs("qsXX")
qd.Parameters(" parDt") = "#9/1/2006#"
With Me.subFom.Form
.RecordSource = qd.SQL
.Requery
End With

in that case, parameter dialog box appear. why?
what's wrong?

*** Sent via Developersdex http://www.developersdex.com ***
Oct 19 '06 #1
1 2519
x taol wrote:
>
Set qd = CurrentDb.Query Defs("qsXX")
qd.Parameters(" parDt") = "#9/1/2006#"
With Me.subFom.Form
.RecordSource = qd.SQL
.Requery
End With

in that case, parameter dialog box appear. why?
what's wrong?
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

You've created an instance of the QueryDef and then set that instance's
parameter. Then you've taken only the QueryDef's SQL and put it into
the RecordSource of the form. That SQL still has the parameter line
("PARAMETERS parDT Date;") without the value because the QueryDef holds
the parameter value, not the SQL string.

You could just do a Replace() to get rid of the PARAMETERS line and
substitute the date value for the parameter name. E.g.:

strSQL = Replace(qd.SQL, "PARAMETERS parDt DateTime;","")
Me!subForm.Form .RecordSource = Replace(strSQL, "parDT","#9/1/2006#")

You don't have to Requery 'cuz changing the RecordSource automatically
does that.
--
MGFoster:::mgf0 0 <atearthlink <decimal-pointnet
Oakland, CA (USA)
** Respond only to this newsgroup. I DO NOT respond to emails **

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBRTgv9YechKq OuFEgEQL1xgCdEZ 18+GOVRMGPpDdp/mkYIReOUfAAoINz
0ba04P5gsxehoru NSWh0O5bL
=DYMY
-----END PGP SIGNATURE-----
Oct 20 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
11365
by: Max Harvey | last post by:
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
7
9479
by: Dee | last post by:
Running an AfterUpdate event procedure, I get the following error: "Too few parameters. Expected 1." My code is as follows: Private Sub DealerID_AfterUpdate() Dim db As DAO.Database
4
5133
by: Polly | last post by:
I had a macro that ran a parameter query and created and opened an Excel file with the system date as part of the file name, but I had to change the file name by hand. So I converted the macro to code using tools-->references. The converted macro included the following statement: DoCmd.OutputTo acQuery, "qselLabelsBloodLog_output", "MicrosoftExcelBiff8(*.xls)", "S:\susan_cheree\lb041129.xls", True, "", 0
9
3470
by: deko | last post by:
I'm trying to export to Excel with this: SELECT INTO .WorksheetName; The problem is with I've tried this:
3
4813
by: priscilla.jenkins | last post by:
Alright, I'm really new to SQL and VBA and all this, so I might be completely off course...but just tell me. I know C and Assembly, but that doesn't help me much here. I'm trying to create a module that creates 5 queries (that a report is based on) based on a table that the user defines. My tables are named by date (not my choice), for example: -ArchivedActions05-20-05 Everything involving that seems fine. I'm getting a syntax error...
24
22651
by: deko | last post by:
I'm trying to log error messages and sometimes (no telling when or where) the message contains a string with double quotes. Is there a way get the query to insert the string with the double quotes? Do I need to use code to scrub each string and remove or escape the double quotes before using it in a query? The error I get is this: Error Number 3075: Syntax error (missing operator) in query expression '"credit card billed by...
21
5772
by: Marc DVer | last post by:
I am trying to create a query that can be loaded as a querydef object but not having to assign values to the parameters if I don't want to. Normally when using a parameter query in VBA my code would go something like this: dim qry as dao.querydef set qry = currentdb.querydefs("myquery") qry.parameters("Par1") = "blah"
0
8329
by: roamnet | last post by:
hi i created database file with .mdf extention ,sql server as a source and use grid view to display data there're no problem in data retrieve and display,but i want to edit it or insert new records there is an error "Incorrect syntax near '-'. Must declare the scalar variable "@UserName". I worked out in design view,code is automatically generated.Iam not able fix the error. Iam working with Visual Web Developer-2005 Express Edition
3
5447
by: myemail.an | last post by:
Hi all, I use Access 2007 and have come across this error a number of times. I have two tables (customer information) which should contain - ideally - the same data. I create a query to compare them based on customer code. The fields are something like: Customer code Balance - Table 1 Balance - Table 2
0
9628
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9464
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10061
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9923
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6722
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5367
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5493
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3622
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2860
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.