I have create a date table in access and visual basic 6 in textbox but when i try to add record there is error message shown. plz help me.

Dani AI

Generated

The thread lacks the exact error text, the SQL being executed, and whether VB6 is using ADO, DAO or ODBC. correctly pointed out the absence of code and asked for the error message. The important diagnostic details to supply are: the exact error message and line, the connection method, the SQL statement, the Access table schema for the date field, and a sample textbox value.

Common causes and quick checks (use these as a checklist when reproducing the problem):

  • Confirm the Access field is Date/Time and whether it allows Null. A text value will fail if the field expects a Date.
  • If concatenating SQL strings, Access date literals must be delimited with # (for example: #2010-02-03#). Locale differences can still cause misinterpretation; using yyyy-mm-dd inside # often helps but is not foolproof.
  • Prefer parameterized commands (ADO/Command parameters or DAO parameters). Parameters avoid format and SQL-injection issues and let the provider handle the conversion.
  • Validate the textbox with IsDate before calling CDate. Treat empty strings explicitly (send Null instead of an empty string).
  • ADO/ODBC parameter markers, provider behavior and reserved field names can also trigger errors; confirm the connection string and field names.

Example pattern (VB6 / ADO) that validates and uses a parameterized insert:

If Len(Trim(Text1.Text)) = 0 Or Not IsDate(Text1.Text) Then
    MsgBox "Invalid date"
    Exit Sub
End If

Dim cmd As ADODB.Command
Set cmd = New ADODB.Command
Set cmd.ActiveConnection = cn  ' cn is an open ADODB.Connection
cmd.CommandText = "INSERT INTO MyTable (DateField) VALUES (?)"
cmd.Parameters.Append cmd.CreateParameter("p1", adDate, adParamInput, 0, CDate(Text1.Text))
cmd.Execute

Passing a properly typed parameter removes most date-format headaches.

Recommended Answers

All 2 Replies

Well what do you know!!!! Another nonexistant code snipped!!!! And low and behold, it is another question!!!!

Well now, lets see where the OP's code could have gone wrong.... Well what do you know!!! No code to examine!!! So I wonder how we are going to help the OP if we don't know what code they are using???

Such a quandry!

what kind of error msg show, so write details plz.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.