changing multiple records with a combo box.

S

sashabaz

I have a form which shows records in continuous format based on a selection
(from a combo box). On the form I have a currency setting for every record.
I wish to have an overall currency setting situated in the form header. If I
change this selection (it should be a combo box) then it updates all the
currency settings on the form to the selection.

Basically I want to update fields after the combo box for Currency has been
updated. I have mainly been working with macros, but there is no "Copy
Value" macro.
 
B

Beetle

You'll need to run an update query from, for example, the After Upate
event of the currency combo box in the header. I can't be specific
without knowing more about your design, so this is just an example
of the basic idea. You'll want to update the currency field in the table
to the current value in the combo box, using a proper Where clause
so that only the selected records get updated (not all the records in
the table).

First, MAKE A BACKUP before you attempt any of the following. Also,
I would add a message box as a precaution to make sure the user really
wants to overwrite the current values, so there is an example of that
in this sample code also.

'###start of sample code###

Private Sub cboUpdateCurrency_AfterUpdate ()

Dim strSQL As String

strSQL = "Update tblSomeTable Set CurrencyField = " _
& Me.cboUpdateCurrency & " Where SomeKeyField =" _
& Me.SomeValue & ";"

If MsgBox("Do you want to update the currency values?", _
vbYesNo, "Update Values") = vbYes Then

CurrentDb.Execute strSQL, dbFailOnError
End If

End Sub

'###end of sample code###

I have added continuation characters in the example to adjust for the
newsgroup line wrap, but you may still need to correct for that also.
 

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