Updating Check Box

M

Mike Wilson

Help Please

I am using the following VB code to append a product selection to an
order detail subform (OrderD1) in Access 97 via unbound, synchronised
Combo boxes (PIDS & PNS) which pull Product Id's & Names from a
Product Table, the quantity required is then entered into text box QTYS
and the line weight is calculated in text box Wts

"Code"
Private Sub AddNew_Click()
DoCmd.RunMacro "Add1st"
Dim DB As DAO.Database
Dim RS As DAO.Recordset
Dim strSQL As String
Set DB = CurrentDb
Set RS = DB.OpenRecordset("OrderD1", dbOpenDynaset)
RS.AddNew
RS!ProductId = Me.PIDS
RS!ProductName = Me.PNS
RS!Qty = Me.QTYS
RS!Lwt = Me.Wts
RS.Update

CurrentDb.Execute "UPDATE OrderD1 SET OrderD1.Select = True;"

Me.PIDS = Null
Me.PNS = Null
Me.Lwts = Null
Me.QTYS = Null

End Sub

"Code End"

The selected product has a checkbox beside it (Select).

I want to update the checkbox for the added product, my code is setting
all the check boxes in the subform to true.

I would be grateful for any assistance
 
G

Glenn

Hi Mike,

The simplest way would be to add the select box to the
recordset you are updating i.e.

RS.AddNew
RS!ProductId = Me.PIDS
RS!ProductName = Me.PNS
RS!Qty = Me.QTYS
RS!Lwt = Me.Wts
RS!Select = True
RS.Update

Other than that you need the OrderD1 key to update the
desired select box. This could be achieved by adding the
following line of code after the RS.update statement:

RS.Bookmark = RS.LastModified

Then make your update statement:

DB.Execute "UPDATE OrderD1 SET OrderD1.Select = True Where
[Key] = RS!Key"

Substituting "Key" with the OrderD1.KeyName.

Rgds,
Glenn.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top