473,503 Members | 1,654 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ADO error adding to recordset

34 New Member
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:

Expand|Select|Wrap|Line Numbers
  1.     Set rst = New ADODB.Recordset
  2.  
  3.  
  4.     rst.Open "tblOrders", CurrentProject.Connection, adOpenDynamic, adLockOptimistic
  5.  
  6.     With rst
  7.         .AddNew
  8.         ![JobID] = """" & Me.txtJobID & """"
  9.         ![JobSubID] = """" & Me.cboJobSubID & """"
  10.         ![JobType] = """" & Me.cboJobType & """"
  11.         ![Model] = """" & Me.cboModel & """"
  12.         ![Lot] = """" & Me.txtLot & """"
  13.         Debug.Print "#" & Me.txtRecDate & "#"
  14.         Debug.Print Format(Me.txtRecDate, "\#mm\/dd\/yyyy\#")
  15.         ![RecievedDate] = Format(Me.txtRecDate, "\#mm\/dd\/yyyy\#")
  16.         Debug.Print "after date"
  17.         ![CustomerID] = Me.cboCustomer.Column(0)
  18.         .Update
  19.     End With
  20.  
  21.     rst.Close
  22.     Set rst = Nothing
Apr 17 '07 #1
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:

Expand|Select|Wrap|Line Numbers
  1.     Set rst = New ADODB.Recordset
  2.  
  3.  
  4.     rst.Open "tblOrders", CurrentProject.Connection, adOpenDynamic, adLockOptimistic
  5.  
  6.     With rst
  7.         .AddNew
  8.         ![JobID] = """" & Me.txtJobID & """"
  9.         ![JobSubID] = """" & Me.cboJobSubID & """"
  10.         ![JobType] = """" & Me.cboJobType & """"
  11.         ![Model] = """" & Me.cboModel & """"
  12.         ![Lot] = """" & Me.txtLot & """"
  13.         Debug.Print "#" & Me.txtRecDate & "#"
  14.         Debug.Print Format(Me.txtRecDate, "\#mm\/dd\/yyyy\#")
  15.         ![RecievedDate] = Format(Me.txtRecDate, "\#mm\/dd\/yyyy\#")
  16.         Debug.Print "after date"
  17.         ![CustomerID] = Me.cboCustomer.Column(0)
  18.         .Update
  19.     End With
  20.  
  21.     rst.Close
  22.     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.
Apr 18 '07 #2
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))
Apr 18 '07 #3
Tetelestai
34 New Member
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)

Expand|Select|Wrap|Line Numbers
  1.     Set rst = New ADODB.Recordset
  2.  
  3.  
  4.     rst.Open "tblOrders", CurrentProject.Connection, adOpenDynamic, adLockOptimistic
  5.     With rst
  6.         .AddNew
  7.         ![JobID] = Me.txtJobID
  8.         ![JobSubID] = Me.cboJobSubID
  9.         ![JobType] = Me.cboJobType
  10.         ![Model] = Me.cboModel
  11.         ![Lot] = Me.txtLot
  12.         ![RecievedDate] = Me.txtRecDate
  13.         ![CustomerID] = Me.cboCustomer.Column(0)
  14.         .Update
  15.     End With
  16.  
  17.     rst.Close
  18.     Set rst = Nothing
Apr 18 '07 #4
pks00
280 Recognized Expert Contributor
Sometimes its easier than u think :)
Apr 18 '07 #5

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

Similar topics

6
46856
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...
1
2176
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...
2
3002
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...
3
6857
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...
7
7228
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...
16
7192
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
1
2890
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...
3
616
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 ...
4
2028
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...
1
3794
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. ...
0
7198
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,...
0
7271
Oralloy
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,...
1
6979
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...
0
7449
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...
0
5570
agi2029
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,...
1
4998
isladogs
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...
0
4666
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...
0
3160
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...
0
3149
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.