473,507 Members | 2,416 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Update Recordset From Code Problem

I am missing something here. I have a pop up form (loads from the
"main form")that displays multiple command buttons. When a user
selects a particular button, the recordset from the main form should be
updated. Here is the code that I have written but it doesnt work. I
get too few parameters on rs1. Can anyone shed some light on what I am
missing? I appreciate help in advance-Corey
Private Sub APPRVD_Click()

Dim dbs As Database, rs As Recordset, rs1 As Recordset

Set dbs = CurrentDb()
Set rs = dbs.OpenRecordset("QRY_NOTES_UPDATE")
Set rs1 = dbs.OpenRecordset("Select PROVISIONAL_STATUS From
CANDIDATES Where CAN_ID = Forms!CANDIDATE_PROFILE!CAN_ID.Value")

With rs
..AddNew
!CAN_ID = Forms!CANDIDATE_PROFILE!CAN_ID
!NOTE_DATE = Now()
!NOTE = "Status Change To Approved"
!NOTE_TYPE = "Status Change"
!NOTE_CREATOR = UserName()
..Update
..Close
End With

With rs1
..Update
!PROVISIONAL_STATUS = "APPROVED"
..Close
End With
End Sub

Nov 13 '05 #1
2 2049
Corey wrote:
I am missing something here. I have a pop up form (loads from the
"main form")that displays multiple command buttons. When a user
selects a particular button, the recordset from the main form should be
updated. Here is the code that I have written but it doesnt work. I
get too few parameters on rs1. Can anyone shed some light on what I am
missing? I appreciate help in advance-Corey
Private Sub APPRVD_Click()

Dim dbs As Database, rs As Recordset, rs1 As Recordset

Set dbs = CurrentDb()
Set rs = dbs.OpenRecordset("QRY_NOTES_UPDATE")
Set rs1 = dbs.OpenRecordset("Select PROVISIONAL_STATUS From
CANDIDATES Where CAN_ID = Forms!CANDIDATE_PROFILE!CAN_ID.Value")

With rs
.AddNew
!CAN_ID = Forms!CANDIDATE_PROFILE!CAN_ID
!NOTE_DATE = Now()
!NOTE = "Status Change To Approved"
!NOTE_TYPE = "Status Change"
!NOTE_CREATOR = UserName()
.Update
.Close
End With

With rs1
.Update
!PROVISIONAL_STATUS = "APPROVED"
.Close
End With
End Sub


Looks like this part of your code needs revision:

With rs1
.AddNew
!PROVISIONAL_STATUS = "APPROVED"
.Update
.Close
End With
--
'---------------
'John Mishefske
'---------------
Nov 13 '05 #2
On 23 Jan 2005 02:16:08 -0800, "Corey" <co**********@yahoo.com> wrote:
I am missing something here. I have a pop up form (loads from the
"main form")that displays multiple command buttons. When a user
selects a particular button, the recordset from the main form should be
updated. Here is the code that I have written but it doesnt work. I
get too few parameters on rs1. Can anyone shed some light on what I am
missing? I appreciate help in advance-Corey
Private Sub APPRVD_Click()

Dim dbs As Database, rs As Recordset, rs1 As Recordset

Set dbs = CurrentDb()
Set rs = dbs.OpenRecordset("QRY_NOTES_UPDATE")
Set rs1 = dbs.OpenRecordset("Select PROVISIONAL_STATUS From
CANDIDATES Where CAN_ID = Forms!CANDIDATE_PROFILE!CAN_ID.Value")

With rs
.AddNew
!CAN_ID = Forms!CANDIDATE_PROFILE!CAN_ID
!NOTE_DATE = Now()
!NOTE = "Status Change To Approved"
!NOTE_TYPE = "Status Change"
!NOTE_CREATOR = UserName()
.Update
.Close
End With

With rs1
.Update
!PROVISIONAL_STATUS = "APPROVED"
.Close
End With
End Sub


John's right, but of course, that's not your problem because your code can't
get that far. I'm assuming your QRY_NOTES_UPDATE uses parameters to know what
record to select, and since you don't provide parameters in your code, I
presume you were trying to get a parameter from a form control - that won't
work here.

When you execute a query via the UI, Access automatically resolves any
parameters that refer to controls on open forms, but this does not happen when
you open a DAO recordset in code. You;ll have to use a Querydef object, and
assign the parameter value in code before opening the recordset using the
..OpenRecordset method of the Querydef object.
Nov 13 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2763
by: Sue Adams | last post by:
I actually have two issues/questions: I have an autonumber field in an access db table that I grab and later use to update a record in another table withing the same db. The code I use to get...
2
3596
by: Joseph Markovich | last post by:
I'm having some trouble with VB in Access 2000. I have a form that the user enters in just one number (in this case, it's a base salary) and then the program is going to do a bunch of math (which...
8
3694
by: Maxi | last post by:
There is a lotto system which picks 21 numbers every day out of 80 numbers. I have a table (name:Lotto) with 22 fields (name:Date,P1,P2....P21) Here is the structure and sample data: ...
9
3195
by: zMisc | last post by:
When I try to update record, I kept getting this error: Row cannot be located for updating. Some values may have been changed since it was last read. No other users are accessing the database...
4
8783
by: mmanojkumar | last post by:
Sir, I have a recordset "ADODC_path.recordset" which takes input from two tables When the field values are put into the textboxes and then edited and updated back into the tables, using the...
1
2447
by: teenagelcruise | last post by:
hi, i have a problem with my code which is i cannot update and addnew data into the database but i can delete the data.plz give me an idea.this is my code that i wrote. <html> <head> <meta...
1
10119
by: sphinney | last post by:
All, I have a ADODB.Recordset in my Access 2002 project. I've been able to successfully add fields to the record set. According the the MS Access help files, I now must update the recordset to...
2
3049
by: Presto | last post by:
I am making a front end mdb so users can enter new members data. I can then import this into the master database on the backend and erase the existing info on the front end to keep the data...
1
2415
Fary4u
by: Fary4u | last post by:
Hi, I'm attempting to update a record via the recordset.update method, However, the recordset object is defined and accesses the correct record that I want to update, as I can retrieve field...
0
7223
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
7319
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
7376
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7031
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...
1
5042
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
4702
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
1542
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
760
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
412
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.