[AccessD] saving values

Bill Patten bill_Patten at earthlink.net
Sat Nov 25 15:24:55 CST 2006


Pedro,

I haven't been following the thread, but perhaps you need an rs.addnew 
instead of rs.edit???

HTH

Bill
----- Original Message ----- 
From: "Pedro Janssen" <pedro at plex.nl>
To: "Access Developers discussion and problem solving" 
<accessd at databaseadvisors.com>
Sent: Saturday, November 25, 2006 12:36 PM
Subject: Re: [AccessD] saving values


Hello Rocky (and Others),

the code is working fine, but only for the first record on the form.
When i try to use it on the second record (after closing) it jumps to record
one and overwrite's the data there.
Trying to put the where statement in it to state that ID = ID, it gives an
error on record two that it expects parameter = 1.

The code that i use now:

Private Sub Form_Close()

Dim db As DAO.Database
Dim rs As DAO.Recordset

Set db = CurrentDb
Set rs = db.OpenRecordset("Select Era, Periode, Epoch, Etage, Tijd FROM
tblFossielData")

rs.Edit
rs!Era = cboEra
rs!Periode = cboPeriode
rs!Epoch = cboEpoch
rs!Etage = cboEtage
rs!Tijd = cboTijd
rs.Update

rs.Close
db.Close

Set rs = Nothing
Set db = Nothing

Me.Requery

End Sub

What can i do about this?

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 9:09 PM
Subject: Re: [AccessD] saving values


> 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
>
>
> -- 
> 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




More information about the AccessD mailing list