473,396 Members | 2,024 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Trouble Defining and Updating Recordset

132 100+
I'm trying to update a field in a table with the value of a text box in a report. Here is what I have:

Private Sub Report_Close()

Dim rs As Recordset

Set rs = CurrentDb.OpenRecordset("OHPA Summary Report Table")

rs.AddNew
rs("Begining Balance") = [Text4]

rs.Update

End Sub


When I run the code, I keep getting a type mismatch on the line where I set rs = currentdb....etc. ANY ideas??? Is there a better way to do this??
Mar 5 '08 #1
8 1450
Stewart Ross
2,545 Expert Mod 2GB
I'm trying to update a field in a table with the value of a text box in a report. Here is what I have:

Private Sub Report_Close()

Dim rs As Recordset

Set rs = CurrentDb.OpenRecordset("OHPA Summary Report Table")

rs.AddNew
rs("Begining Balance") = [Text4]

rs.Update

End Sub


When I run the code, I keep getting a type mismatch on the line where I set rs = currentdb....etc. ANY ideas??? Is there a better way to do this??
Hi. There is more than one kind of recordset, and unfortunately they have different methods and properties. As it is the Access DAO-type recordset you are using your problems should be resolved if you qualify your DIM as
Expand|Select|Wrap|Line Numbers
  1. Dim rs as DAO.Recordset
If the DAO qualifer is not recognised you will need to set a reference to the Microsoft DAO object library via Tools, references in the VB editor.

-Stewart
Mar 5 '08 #2
Proaccesspro
132 100+
Hi. There is more than one kind of recordset, and unfortunately they have different methods and properties. As it is the Access DAO-type recordset you are using your problems should be resolved if you qualify your DIM as
Expand|Select|Wrap|Line Numbers
  1. Dim rs as DAO.Recordset
If the DAO qualifer is not recognised you will need to set a reference to the Microsoft DAO object library via Tools, references in the VB editor.

-Stewart

Yep, it dod not like the DOA qualifier. I tried to get to the references option but it is greyed out........
Mar 5 '08 #3
Stewart Ross
2,545 Expert Mod 2GB
Yep, it dod not like the DOA qualifier. I tried to get to the references option but it is greyed out........
Perhaps you didn't stop the debugger (by pressing the little rectangular reset button) before trying to set the reference??
Mar 5 '08 #4
Proaccesspro
132 100+
Perhaps you didn't stop the debugger (by pressing the little rectangular reset button) before trying to set the reference??
Yes, you're right...seems to work OK now....One last question, what command can I use to delete all records in a table?
Mar 5 '08 #5
Stewart Ross
2,545 Expert Mod 2GB
Yes, you're right...seems to work OK now....One last question, what command can I use to delete all records in a table?
Well, living dangerously you can use
Expand|Select|Wrap|Line Numbers
  1. Docmd.RunSQL "DELETE * FROM yourtablename;"
You would need to turn warnings off and on before and after using
Expand|Select|Wrap|Line Numbers
  1. Docmd.Setwarnings False (or True)
or a similar method.

-Stewart
Mar 6 '08 #6
Proaccesspro
132 100+
Well, living dangerously you can use
Expand|Select|Wrap|Line Numbers
  1. Docmd.RunSQL "DELETE * FROM yourtablename;"
You would need to turn warnings off and on before and after using
Expand|Select|Wrap|Line Numbers
  1. Docmd.Setwarnings False (or True)
or a similar method.

-Stewart
It does not like it. Says I have a syntax error.

DoCmd.RunSQL "DELETE * FROM DEHP Summary Report Table;"
Mar 6 '08 #7
Stewart Ross
2,545 Expert Mod 2GB
It does not like it. Says I have a syntax error.

DoCmd.RunSQL "DELETE * FROM DEHP Summary Report Table;"
Hi. Where the name of a field or table has spaces in it you must enclose it in square brackets.
Expand|Select|Wrap|Line Numbers
  1. DoCmd.RunSQL "DELETE * FROM [DEHP Summary Report Table];"
-Stewart
Mar 6 '08 #8
Proaccesspro
132 100+
Hi. Where the name of a field or table has spaces in it you must enclose it in square brackets.
Expand|Select|Wrap|Line Numbers
  1. DoCmd.RunSQL "DELETE * FROM [DEHP Summary Report Table];"
-Stewart
B-I-N-G-O!!! Thanks!
Mar 6 '08 #9

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

Similar topics

1
by: Roy Adams | last post by:
Hi everyone I'm trying to build a shopping cart app using a db the part I'm stuck on is the fact that, if someone adds a product that they have previously added to the cart. I've got it set up to...
6
by: RC | last post by:
My code below will loop through all the records in the table, and when the if statement is true it goes to the ***Me.ContainerNumberProductsTable = GETContainerNumber.Value*** bit like should but...
0
by: cwbp17 | last post by:
I'm having trouble updating individual datagrid cells. Have two tables car_master (columns include Car_ID, YEAR,VEHICLE) and car_detail (columns include Car_ID,PRICE,MILEAGE,and BODY);both tables...
2
by: barret bonden | last post by:
(closest newsgroup I could find) Error Type: ADODB.Recordset (0x800A0CB3) Current Recordset does not support updating. This may be a limitation of the provider, or of the selected locktype....
34
by: Jeff | last post by:
For years I have been using VBA extensively for updating data to tables after processing. By this I mean if I had to do some intensive processing that resulted in data in temp tables, I would have...
2
by: Alexey.Murin | last post by:
The application we are developing uses MS Access 2003 database (with help of ADO). We have noticed that during massive records updating the size of the mdb file increases dramatically (from 3-4 to...
5
by: Hexman | last post by:
I've come up with an error which the solution eludes me. I get the error: >An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in HRTest.exe > >Additional...
3
by: jason.teen | last post by:
Hi, I'm trying to update a recordset (change field values, delete records) but I have found that it actaully is changing the original tables. When when I was hoping for was actaully that the...
1
by: George | last post by:
I have just loaded Access 2007 and am having trouble creating a new database where I update my table from a query. I have done this numerous times in years past but am totally frustrated tryng to...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
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
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,...
0
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...

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.