-
May 30th, 2003, 12:47 AM
#1
Help Whats wrong with my code?
Hi to all VB experts!
i'm a newbie in VB. I have this problem regrading dateformat. can i use the format function inside a query?? i dont know whats wrong with my code. it returns an error message "too few parameters. Expected1".
The code gets the user inputs "months.text" and "year.text" and gets the records that are equal to the month and year of the date field.
The date field format is mm/dd/yyyy and the user inputs the month with mmm format (i'm using a combo box. user can choose whether he/she wants to view the data with the month Jan, Feb, and so on.)
Please help me with my dilemma.
Thanks in advance!!
CODE:
Data1.RecordSource = "Select publisher, address, postalcode, tel, fax, isbn, publication, author, edition, l_used, b_used From isbn Where datepart('mmm', #" & Format(Date, "mmm-dd-yyyy") & "#) = " & months.Text & " AND datepart('yyyy',date) = " & year.Text & " "
Data1.Refresh
-
May 30th, 2003, 12:57 AM
#2
How about this one..
Data1.RecordSource = "Select publisher, address, postalcode, tel, fax, isbn, publication, author, edition, l_used, b_used From isbn Where Format([Date], ""mmm"") = '" & months.Text & "' AND format([Date], ""yyyy"") = '" & year.Text & "'"
Busy
-
May 30th, 2003, 12:59 AM
#3
Kjcarrots,
I am not familiar with DATEPART, so that may be the problem.
I have always used the SQL commands YEAR and MONTH, to achieve what you are trying to do.
Purhaps you could try using those instead.
(P.S. MONTH gives the months number ie 1, 2 .. 12, but there is also MONTHNAME, which give the name of the month. *DUH* )
Mike
-
May 30th, 2003, 01:35 AM
#4
Thanks it worked!!!!
Thanks guys!! it worked!! woohoo!!
*jumps with delight*
Joy
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|