You could run the query in VBA code by putting that code into the
AfterUpdate event procedure for the combo box.
You can refer to the control in a saved query like this:
UPDATE tblTable SET fldField = Forms!FormName!ComboBoxName
If you have spaces in the form name or control name, you must enclose
it in square brackets:
UPDATE tblTable SET fldField = Forms![form name]![combo box name]
You could also construct the SQL in VBA code, like this:
Function ConstructSQL() As String
Dim strSQL As String
strSQL = "UPDATE tblTable SET fldField = "
If IsNull(cboList.Value) Then
strSQL = strSQL & "NULL"
Else
strSQL = strSQL & cboList.Value
End If
ConstructSQL = strSQL
End Function
If the field is a Text field, then the next to last line must include
quotes:
strSQL = strSQL & """" & cboList.Value & """"
Each approach has limitations.
You can run the query in the combo box's AfterUpdate event
procedure. You can either pass the name of your saved query or the
SQL string described above:
Private Sub cboList_AfterUpdate()
Dim strParameter As String
'if you choose the saved query approach, uncomment the next line
'strParameter = "qrySavedQuery"
'if you choose the saved query approach, comment out the next line
strParameter = GenerateSQL
With CurrentDb
.Execute strParameter
.Close
End With
End Sub
Hope this helps.
Good luck,
Peter Hoogenboom
--- In [email protected], "dalpalbj" <[EMAIL PROTECTED]> wrote:
>
> I need to fill all of the records in a field with the same value. I
would like to select the value from a list and have it update. I
believe I need a combo box with an udate query. I can do these two
things seperately but don't know how to get the value selected into
the query.
>