Getting a type mismatch error (-2147352571 (80020005)) on this line of code
![RecievedDate] = Format(Me.txtRecDate, "\#mm\/dd\/yyyy\#")
I can't find the error number refenced anywhere. Any hints or helps would be appriciated.
I'm using Access 2007
Here is more code: - Set rst = New ADODB.Recordset
-
-
-
rst.Open "tblOrders", CurrentProject.Connection, adOpenDynamic, adLockOptimistic
-
-
With rst
-
.AddNew
-
![JobID] = """" & Me.txtJobID & """"
-
![JobSubID] = """" & Me.cboJobSubID & """"
-
![JobType] = """" & Me.cboJobType & """"
-
![Model] = """" & Me.cboModel & """"
-
![Lot] = """" & Me.txtLot & """"
-
Debug.Print "#" & Me.txtRecDate & "#"
-
Debug.Print Format(Me.txtRecDate, "\#mm\/dd\/yyyy\#")
-
![RecievedDate] = Format(Me.txtRecDate, "\#mm\/dd\/yyyy\#")
-
Debug.Print "after date"
-
![CustomerID] = Me.cboCustomer.Column(0)
-
.Update
-
End With
-
-
rst.Close
-
Set rst = Nothing
4 2078 ADezii 8,834
Recognized Expert Expert
Getting a type mismatch error (-2147352571 (80020005)) on this line of code
![RecievedDate] = Format(Me.txtRecDate, "\#mm\/dd\/yyyy\#")
I can't find the error number refenced anywhere. Any hints or helps would be appriciated.
I'm using Access 2007
Here is more code: - Set rst = New ADODB.Recordset
-
-
-
rst.Open "tblOrders", CurrentProject.Connection, adOpenDynamic, adLockOptimistic
-
-
With rst
-
.AddNew
-
![JobID] = """" & Me.txtJobID & """"
-
![JobSubID] = """" & Me.cboJobSubID & """"
-
![JobType] = """" & Me.cboJobType & """"
-
![Model] = """" & Me.cboModel & """"
-
![Lot] = """" & Me.txtLot & """"
-
Debug.Print "#" & Me.txtRecDate & "#"
-
Debug.Print Format(Me.txtRecDate, "\#mm\/dd\/yyyy\#")
-
![RecievedDate] = Format(Me.txtRecDate, "\#mm\/dd\/yyyy\#")
-
Debug.Print "after date"
-
![CustomerID] = Me.cboCustomer.Column(0)
-
.Update
-
End With
-
-
rst.Close
-
Set rst = Nothing
You are asking a Date/Time Field ([ReceivedDate] within the underlying Recordset to store the formatted value Format(Me.txtRecDate, "\#mm\/dd\/yyyy\#") which it cannot because of the inclusion of the # characters. Either convert the [ReceivedDate] Field to Text, or reformat it as such: Format(Me.txtRecDate, "mm/dd/yyyy"). Hope this helps.
pks00 280
Recognized Expert Contributor
Why dont u just do this, did this not work for you?
It should recognise that txtRecDate is a datefield
![RecievedDate] = Me.txtRecDate
Not sure about this
![RecievedDate] = "#" & Me.txtRecDate & "#"
or
![RecievedDate] = CDATE(Me.txtRecDate)
or long winded way
![RecievedDate] = dateserial( year(Me.txtRecDate), month(Me.txtRecDate), day(Me.txtRecDate))
Why dont u just do this, did this not work for you?
It should recognise that txtRecDate is a datefield
![RecievedDate] = Me.txtRecDate
your correct that did work. Thanks. I knew it was something obvious.
correct code below (for posterity) - Set rst = New ADODB.Recordset
-
-
-
rst.Open "tblOrders", CurrentProject.Connection, adOpenDynamic, adLockOptimistic
-
With rst
-
.AddNew
-
![JobID] = Me.txtJobID
-
![JobSubID] = Me.cboJobSubID
-
![JobType] = Me.cboJobType
-
![Model] = Me.cboModel
-
![Lot] = Me.txtLot
-
![RecievedDate] = Me.txtRecDate
-
![CustomerID] = Me.cboCustomer.Column(0)
-
.Update
-
End With
-
-
rst.Close
-
Set rst = Nothing
pks00 280
Recognized Expert Contributor
Sometimes its easier than u think :)
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Matthew Louden |
last post by:
The following ASP code yields the following error, but actually the new
record is stored
in database. The same error happens when the application deletes a record,
such as
sqlStmt ="delete from...
|
by: Dalan |
last post by:
I'm experiencing a Query Syntax Error with an Access 97 Db. Actually,
the query performs as expected when adding any new records or editing
existing ones and even deleting records, EXCEPT when the...
|
by: Steve Jorgensen |
last post by:
When writing VB or VBA code that works with databases or other external
libraries that cannot be trusted to automatically do the right thing when
references to their objects are arbitrarily...
|
by: Nathan Bloomfield |
last post by:
Hi there,
I am having difficulty with a piece of code which would work wonders
for my application if only the error trapping worked properly.
Basically, it works as follows:
- adds records...
|
by: astro |
last post by:
Anyone have suggestions on where to troubleshoot this error?
Background:
-Access 2k v. 9.0.6926 sp3
- front and backend on production server (wiindows 2k)
-accessed via Citrix
-front-end is...
| |
by: TD |
last post by:
This is the code under a command button -
Dim ctl As Control
For Each ctl In Me.Controls
If ctl.BackColor <> RGB(255, 255, 255) Then
ctl.BackColor = RGB(255, 255, 255)
End If
Next ctl
|
by: Kosmös Pollard |
last post by:
Hey guys, I'm rather new to access and can not seem to figure out what
is wrong with this code I will post below...but first...it was working
perfectly fine before I added this:
recSet2.Edit...
|
by: amatuer |
last post by:
ADODB.Recordset error '800a0cb3'
Current Recordset does not support updating. This may be a limitation
of the provider, or of the selected locktype.
/devag/newProjSave.asp, line 321
...
|
by: breadhead |
last post by:
Good morning, all.
I am creating an Access 2002 application to run on XP clients and I'm struggling with the task of testing whether a single-field record exists before allowing the user to add it...
|
by: morrisqueto |
last post by:
Hello,
One of my websites just started sending a new rare error. The site has been working for almost 2 years without trouble, but today morning started giving away this error in all my views.
...
|
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,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
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...
|
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...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
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...
| |
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |