[AccessD] saving values

Beach Access Software bchacc at san.rr.com
Fri Nov 24 14:09:39 CST 2006


Pedro:

Just off the top and untested:

Dim db as DAO.Database
Dim rs as DAO.Recordset

Set db = CurrentDb
Set rs = db.OpenRecordset("Select fldOne, fldTwo, fldThree FROM tblMyTable
WHERE fldPK = " & lngPrimaryKey) 

' Note: You could use any criteria you want in the WHERE clause; doesn't
have to be the primary key.

rs.Edit
rs!fldOne = cboComboBox1
rs!fldTwo = cboComboBox2
rs!fldThree = cboComboBox3
rs.Update

rs.Close
db.Close

set rs = Nothing
set db = Nothing

Me.Requery (assuming you want the values to show on the bound form.


Or here's another approach which I think should work but I haven't tested:

Set db = CurrentDb
Db.Execute "UPDATE tblMyTable SET tblMyTable.fldOne = '" & cboComboBox1 &
"', tblMyTable.fldTwo= '" & cboComboBox2 & "', tblMyTable.fldThree = '" &
cboComboBox3 & "';"

Note that I have assumes that the values are string values and so need to
have preceding and following apostrophes.  If the values are numeric then
they won't need the '.

I'm sure someone else looking at this code will make the appropriate
corrections.

Regards,

Rocky


-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Pedro Janssen
Sent: Thursday, November 23, 2006 3:35 PM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] saving values

Hello Rocky,

could you give me an example of that, preferably in a example database.
I have tried several things until now but nothing is working perfect.

Pedro Janssen


----- Original Message ----- 
From: "Beach Access Software" <bchacc at san.rr.com>
To: "'Access Developers discussion and problem solving'" 
<accessd at databaseadvisors.com>
Sent: Friday, November 24, 2006 12:07 AM
Subject: Re: [AccessD] saving values


> I'd use Dao, open the record in question, push the value in, and requery 
> the
> form.
>
> Rocky
>
>
> -----Original Message-----
> From: accessd-bounces at databaseadvisors.com
> [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Pedro Janssen
> Sent: 23 November 2006 13:32
> To: AccessD
> Subject: [AccessD] saving values
>
> Hello Group,
>
> i still have troubles saving values from unbound comboxes (cascade) in 
> table
> fields.
>
> What is the best way to do this.
>
> Pedro Janssen
> -- 
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
>
> -- 
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.5.430 / Virus Database: 268.14.14/547 - Release Date: 
> 22/11/2006
> 17:41
>
>
> -- 
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
> 

-- 
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com

-- 
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.430 / Virus Database: 268.14.14/547 - Release Date: 22/11/2006
17:41
 




More information about the AccessD mailing list