By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,157 Members | 891 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,157 IT Pros & Developers. It's quick & easy.

Date

P: 56
the date Formats in VB6 n in access are different. i have written an insert query for inserting all details including date into the database but it is not working. i think it is because of this format difference. how do i handle it???
Feb 1 '08 #1
Share this Question
Share on Google+
16 Replies


lotus18
100+
P: 866
the date Formats in VB6 n in access are different. i have written an insert query for inserting all details including date into the database but it is not working. i think it is because of this format difference. how do i handle it???
Can you post your sql statement here? Did you check the datatypes of your fields?
Did you enclosed the dates in your sql query with #?

Rey Sean
Feb 1 '08 #2

P: 68
the date Formats in VB6 n in access are different. i have written an insert query for inserting all details including date into the database but it is not working. i think it is because of this format difference. how do i handle it???


Hey,
u can take the Date as String, then perform ur other tasks.
Feb 1 '08 #3

daniel aristidou
100+
P: 491
Hey,
u can take the Date as String, then perform ur other tasks.
This is unadvisable.....
Feb 1 '08 #4

100+
P: 274
You should format your data before your query in a format that is acceptable in Access something like this:
Format$(txtdate.Text, "m/dd/yy")
Regards
Feb 2 '08 #5

P: 68
This is unadvisable.....
Hi daniel aristidou,
Text1.text is String or other type Data in creative1 ?. Reply me. If u create any mad like comment, u must think before abt that.

Thnks,
shuvo2k6
Feb 2 '08 #6

100+
P: 274
In my reply I assumed you have entered your data in a textbox that you want to convert. I think you better post what you have in your code. It will be far easy to suggest any thing that will help you.
Feb 2 '08 #7

VACEPROGRAMER
100+
P: 168
Why don't you samply type DATE FORMATS in VB help. And you have what you want

*VACE*
Feb 2 '08 #8

P: 1
please post your insert code...
Feb 2 '08 #9

P: 68
In VB6:

Private Sub Command1_Click()
Text1.Text = Format(Date, "dd mmmm, yyyy")
End Sub
Feb 3 '08 #10

P: 56
rs.Open "insert into Invoice_master(Inv_No,Inv_Date,Inv_Type,Cust_Code, Salesman_Code,Due_Date) values(" & Val(txtInvNo.Text) & ",'" & txtDate.Text & "','" & txtInvType.Text & "'," & Val(txtCustCode.Text) & "," & Val(txtSaleCode.Text) & ",'" & txtDue.Text & "')", con, 3, 3


This is the insert statement. tell me where to make changes.
Feb 3 '08 #11

lotus18
100+
P: 866
rs.Open "INSERT INTO Invoice_master(Inv_No,Inv_Date,Inv_Type,Cust_Code, Salesman_Code,Due_Date) VALUES " & Val(txtInvNo.Text) & ",'" & txtDate.Text & "','" & txtInvType.Text & "'," & Val(txtCustCode.Text) & "," & Val(txtSaleCode.Text) & ",'" & txtDue.Text & "')", con, 3, 3


This is the insert statement. tell me where to make changes.
Hi

Change your codes to
Expand|Select|Wrap|Line Numbers
  1. rs.Open "INSERT INTO Invoice_master(Inv_No,Inv_Date,Inv_Type,Cust_Code,Salesman_Code,Due_Date) VALUES (" & Val(txtInvNo.Text) & ",#" & txtDate.Text & "#,'" & txtInvType.Text & "'," & Val(txtCustCode.Text) & "," & Val(txtSaleCode.Text) & ",#" & txtDue.Text & "#)", con, 3, 3
  2.  
Rey Sean
Feb 3 '08 #12

P: 56
Hi

Change your codes to
Expand|Select|Wrap|Line Numbers
  1. rs.Open "INSERT INTO Invoice_master(Inv_No,Inv_Date,Inv_Type,Cust_Code,Salesman_Code,Due_Date) VALUES (" & Val(txtInvNo.Text) & ",#" & txtDate.Text & "#,'" & txtInvType.Text & "'," & Val(txtCustCode.Text) & "," & Val(txtSaleCode.Text) & ",#" & txtDue.Text & "#)", con, 3, 3
  2.  
Rey Sean



I tried the above query bt I am getting the following error....

Syntax error in date in query expression '# #' .
Feb 3 '08 #13

lotus18
100+
P: 866
I tried the above query bt I am getting the following error....

Syntax error in date in query expression '# #' .
Really?, May I see your sample value in txtDate and txtDue. Are your Inv_Date and Due_Date are Date/Time Datatypes?

Rey Sean
Feb 3 '08 #14

P: 56
Really?, May I see your sample value in txtDate and txtDue. Are your Inv_Date and Due_Date are Date/Time Datatypes?

Rey Sean
They are Short Dates....
sample:-3/2/2008
Feb 3 '08 #15

lotus18
100+
P: 866
They are Short Dates....
sample:-3/2/2008
Did you check the datatypes of Inv_Date and Due_Date?

if you're using that format, try this
Expand|Select|Wrap|Line Numbers
  1. Format(Inv_Date, "d/m/yyyy")
  2. Format(Due_Date, "d/m/yyyy")
  3.  

Rey Sean
Feb 3 '08 #16

Expert 5K+
P: 8,434
Syntax error in date in query expression '# #' .
This seems to imply that one or the other of your textboxes was empty. What I'd suggest as a debugging aid is to set a break point and copy/paste here the actual string which is being passed to the SQL interpreter. We've seen the code, but I believe we need to see the result of the code.

In other words, set a break point on the Rs.Open statement. When it breaks, go to Immediate window and enter...
Expand|Select|Wrap|Line Numbers
  1. Print "INSERT INTO Invoice_master(Inv_No,Inv_Date,Inv_Type,Cust_Code,  Salesman_Code,Due_Date) VALUES (" & Val(txtInvNo.Text) & ",#" & txtDate.Text & "#,'" & txtInvType.Text & "'," & Val(txtCustCode.Text) & "," & Val(txtSaleCode.Text) & ",#" & txtDue.Text & "#)"
Feb 3 '08 #17

Post your reply

Sign in to post your reply or Sign up for a free account.