Connecting Tech Pros Worldwide Help | Site Map
 
 
LinkBack Thread Tools Search this Thread
  #1  
Old May 16th, 2006, 03:25 AM
ApexData@gmail.com
Guest
 
Posts: n/a
Default Can't Make a Simple Change to a Record in a Single Table

Hello

I'm trying to save data to an Existing Record in a single table. These
fields
are not on my Form.
It is not saving the data to the record ???


Dim db As DAO.Database
Dim rs As DAO.Recordset
Set db = CurrentDb
strSQL = "SELECT * FROM [T-ADXOR] Where ID = 19"
Set rs = db.OpenRecordset(strSQL, dbOpenForwardOnly)
If rs.BOF = False And rs.EOF = False Then
[Field1] = strPassStamp
[Field2] = strPermStamp
MsgBox [Field1] '<------- The values are showing but not saving
MsgBox [Field2] '<------- " "
End If

ALSO I am in desperate need of good reference material advice. I spend
ALL day
hunting for syntax & rules information. Anything one can recommend?

ThankYou

  #2  
Old May 16th, 2006, 03:45 AM
Bob Quintal
Guest
 
Posts: n/a
Default Re: Can't Make a Simple Change to a Record in a Single Table

"ApexData@gmail.com" <ApexData@gmail.com> wrote in
news:1147745785.705916.90720@g10g2000cwb.googlegro ups.com:
[color=blue]
> Hello
>
> I'm trying to save data to an Existing Record in a single
> table. These fields
> are not on my Form.
> It is not saving the data to the record ???
>
>
> Dim db As DAO.Database
> Dim rs As DAO.Recordset
> Set db = CurrentDb
> strSQL = "SELECT * FROM [T-ADXOR] Where ID = 19"
> Set rs = db.OpenRecordset(strSQL, dbOpenForwardOnly)
> If rs.BOF = False And rs.EOF = False Then
> [Field1] = strPassStamp
> [Field2] = strPermStamp
> MsgBox [Field1] '<------- The values are showing but
> not saving MsgBox [Field2] '<------- " "
> End If
>
> ALSO I am in desperate need of good reference material advice.
> I spend ALL day
> hunting for syntax & rules information. Anything one can
> recommend?
>
> ThankYou
>[/color]

add the two statements. I'd also qualify the two statements
explicitly
[color=blue]
> If rs.BOF = False And rs.EOF = False Then[/color]
rs.edit '<---- added[color=blue]
> rs![Field1] = strPassStamp '<---- improved
> rs![Field2] = strPermStamp '<---- improved[/color]
rs.update '<---- added[color=blue]
> End If[/color]


as to documentation, buy or borrow Access Developer's Handbook
by Getz et al.

--
Bob Quintal

PA is y I've altered my email address.
  #3  
Old May 16th, 2006, 03:55 AM
Allen Browne
Guest
 
Posts: n/a
Default Re: Can't Make a Simple Change to a Record in a Single Table

Suggestions:

1. Make sure you have:
Option Explicit
at the top of every module. This will prevent Access from just making up a
variable for any name it does not recognise.

2. Before you can change the fields of a record, you need to Edit, and
afterwards to Update:
rs.Edit
'change the fields here
rs.Update

3. Refer to the fields of the recordset like this:
rs![Field1] = strPassStamp

Instead of opening a recordset, you could also do it by executing an Update
query statement.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

<ApexData@gmail.com> wrote in message
news:1147745785.705916.90720@g10g2000cwb.googlegro ups.com...[color=blue]
> Hello
>
> I'm trying to save data to an Existing Record in a single table. These
> fields
> are not on my Form.
> It is not saving the data to the record ???
>
>
> Dim db As DAO.Database
> Dim rs As DAO.Recordset
> Set db = CurrentDb
> strSQL = "SELECT * FROM [T-ADXOR] Where ID = 19"
> Set rs = db.OpenRecordset(strSQL, dbOpenForwardOnly)
> If rs.BOF = False And rs.EOF = False Then
> [Field1] = strPassStamp
> [Field2] = strPermStamp
> MsgBox [Field1] '<------- The values are showing but not saving
> MsgBox [Field2] '<------- " "
> End If
>
> ALSO I am in desperate need of good reference material advice. I spend
> ALL day
> hunting for syntax & rules information. Anything one can recommend?
>
> ThankYou[/color]


  #4  
Old May 16th, 2006, 04:55 AM
ApexData@gmail.com
Guest
 
Posts: n/a
Default Re: Can't Make a Simple Change to a Record in a Single Table


ThankYou

Took Your Advice and It Worked!

  #5  
Old May 16th, 2006, 05:55 AM
Lyle Fairfield
Guest
 
Posts: n/a
Default Re: Can't Make a Simple Change to a Record in a Single Table

CurrentDb.Execute "UPDATE [T-ADXOR] SET [Field1] = '" & strPassStamp &
"', [Field2] = '" & strPermStamp & "' WHERE ID = 19"

(which will result in this query string being executed)
UPDATE [T-ADXOR] SET [Field1] = 'qwerty', [Field2] = 'asdfgh' WHERE ID
= 19
assuming
strPassStamp = "qwerty"
strPermStamp = "asdfgh"

I discourage the use of DAO Recordsets except in unusual circimstances.
They are slow, inefficient, dangerous and require (too) many lines of
code.

  #6  
Old May 16th, 2006, 11:15 AM
rkc
Guest
 
Posts: n/a
Default Re: Can't Make a Simple Change to a Record in a Single Table

ApexData@gmail.com wrote:
[color=blue]
> ALSO I am in desperate need of good reference material advice. I spend
> ALL day
> hunting for syntax & rules information. Anything one can recommend?[/color]

The Help files via the Object Browser or any web search engine.
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 205,338 network members.