E
Edward
Hi, All...
I have an Access 2000 database that has a bound form with bound combo boxes.
I want the user to have the ability to update a city after a prompt asking
to do so.
The code below was copied from another form that is unbound, and the
combobox is unbound. It updates just fine and moves to the next field on
the unbound form. However, when I use the same code on the bound form (with
the bound combobox), it DOES update the field, but it changes to the next
record.
Is there a way to force it to stay on the current record, or at the very
least move BACK to the same record from which it originated (I'd prefer the
first one)? I've never tried RecordSetClone or Bookmark properties before,
and what I've tried has failed--even from what was I copied directly.
Probably a problem with me. I would just like this to update the combobox
and move to the next field. Ultimately there will be at least three of
these comboboxes on the form, and I don't want to have too much overhead on
the programming side to do this.
I would appreciate any help you might offer on this.
Many thanks in advance
Edward
********CODE START********
Private Sub City_ID_NotInList(strNewData As String, intResponse As Integer)
Dim db As Database
Dim intStyle As Integer
Set db = CurrentDb
intStyle = vbYesNo + vbDefaultButton2 + vbQuestion
DoCmd.Beep
intResponse = MsgBox("The city " & Chr(34) & strNewData & Chr(34) & "
is not in the list." & Chr(13) & "Do you wish to add it?", intStyle, "Add
City?")
If intResponse = vbNo Then
Me.Undo
Me.City_ID = Null
Close
Else
db.Execute "Insert into tbl_Cities(City) Values (" & Chr(34) &
strNewData & Chr(34) & ")"
intResponse = acDataErrAdded
End If
Exit_NotInList:
Exit Sub
End Sub
********CODE END********
I have an Access 2000 database that has a bound form with bound combo boxes.
I want the user to have the ability to update a city after a prompt asking
to do so.
The code below was copied from another form that is unbound, and the
combobox is unbound. It updates just fine and moves to the next field on
the unbound form. However, when I use the same code on the bound form (with
the bound combobox), it DOES update the field, but it changes to the next
record.
Is there a way to force it to stay on the current record, or at the very
least move BACK to the same record from which it originated (I'd prefer the
first one)? I've never tried RecordSetClone or Bookmark properties before,
and what I've tried has failed--even from what was I copied directly.
Probably a problem with me. I would just like this to update the combobox
and move to the next field. Ultimately there will be at least three of
these comboboxes on the form, and I don't want to have too much overhead on
the programming side to do this.
I would appreciate any help you might offer on this.
Many thanks in advance
Edward
********CODE START********
Private Sub City_ID_NotInList(strNewData As String, intResponse As Integer)
Dim db As Database
Dim intStyle As Integer
Set db = CurrentDb
intStyle = vbYesNo + vbDefaultButton2 + vbQuestion
DoCmd.Beep
intResponse = MsgBox("The city " & Chr(34) & strNewData & Chr(34) & "
is not in the list." & Chr(13) & "Do you wish to add it?", intStyle, "Add
City?")
If intResponse = vbNo Then
Me.Undo
Me.City_ID = Null
Close
Else
db.Execute "Insert into tbl_Cities(City) Values (" & Chr(34) &
strNewData & Chr(34) & ")"
intResponse = acDataErrAdded
End If
Exit_NotInList:
Exit Sub
End Sub
********CODE END********