DownwardSix
Technical User
I have a ComboBox that selects the current record for a form (Location Name).
I then have an Add Location button that allows user to add a new Location Name which turns off the ComboBox, turns on a TextBox to add the name and a Add Button that turn the TextBox off and the ComboBox Back on. I would like the value in the combo box to update to the new Location when the Add Button is clicked, but it does not, it retains the previous value, even though the the form and sub form update to the new record.
Code on Add Button Click:
Private Sub Add_Button_Click()
On Error GoTo Err_Add_Button_Click
' Set New Record
Dim rs As Object
Set rs = Me.Recordset.Clone
' Turn On & Off Form Features
Me![AddLocation_Button].Visible = True
Me![LocationName].Visible = False
Me![LocationName_Label].Visible = False
Me![Select_LocationName].Visible = True
Me![Select_LocationName_Label].Visible = True
DoCmd.GoToControl "Select_LocationName"
'Set to Record
rs.FindFirst "[LocationID] = " & Str(Nz(Me![Select_LocationName], 0))
'If Not rs.EOF Then Me.Bookmark = rs.Bookmark
Select_LocationName.Requery
Me![Add_Button].Visible = False
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acRefresh, , acMenuVer70
Exit_Add_Button_Click:
Exit Sub
Err_Add_Button_Click:
MsgBox Err.Description
Resume Exit_Add_Button_Click
End Sub
I then have an Add Location button that allows user to add a new Location Name which turns off the ComboBox, turns on a TextBox to add the name and a Add Button that turn the TextBox off and the ComboBox Back on. I would like the value in the combo box to update to the new Location when the Add Button is clicked, but it does not, it retains the previous value, even though the the form and sub form update to the new record.
Code on Add Button Click:
Private Sub Add_Button_Click()
On Error GoTo Err_Add_Button_Click
' Set New Record
Dim rs As Object
Set rs = Me.Recordset.Clone
' Turn On & Off Form Features
Me![AddLocation_Button].Visible = True
Me![LocationName].Visible = False
Me![LocationName_Label].Visible = False
Me![Select_LocationName].Visible = True
Me![Select_LocationName_Label].Visible = True
DoCmd.GoToControl "Select_LocationName"
'Set to Record
rs.FindFirst "[LocationID] = " & Str(Nz(Me![Select_LocationName], 0))
'If Not rs.EOF Then Me.Bookmark = rs.Bookmark
Select_LocationName.Requery
Me![Add_Button].Visible = False
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acRefresh, , acMenuVer70
Exit_Add_Button_Click:
Exit Sub
Err_Add_Button_Click:
MsgBox Err.Description
Resume Exit_Add_Button_Click
End Sub