T
Tammy F
I have 2 fields in a table - a station and a use checkbox. This is only used
for set-up purposes... but I'd like the user to check boxes on the subform
and have a sentence show up on the main form in a field.
Example:
Station Use
Cheese x
Sauce
Chips x
Salsa
Sentence would look like: Cheese, Chips
My programming works, except I get an error because it can't go to specified
record when I am on the last record. For some reason - .movefirst and
..movenext don't want to work.
Here is my code. Thank you for any help! Tammy
Private Sub use_AfterUpdate()
Dim stationdesc As String
stationdesc = ""
Dim stationone As String
Dim dbs As DAO.Database
Dim rsZips As DAO.Recordset
Set dbs = CurrentDb
Set rsZips = dbs.OpenRecordset("tlist_station")
With rsZips
If .EOF = False And .BOF = False Then
'.MoveFirst
DoCmd.GoToRecord , , acFirst
Do While .EOF = False
stationone = IIf(Me!use = -1, Me!Station & ", ", "")
stationdesc = stationdesc & stationone
'.MoveNext
On Error GoTo Err_exitloop_Click
DoCmd.GoToRecord , , acNext
Loop
End If
End With
Exit_exitloop_Click:
rsZips.Close
Set rsZips = Nothing
dbs.Close
Set dbs = Nothing
stationlen = Len(stationdesc)
Forms!frm_menu_item_setup!Station = Left(stationdesc, stationlen - 2)
Exit Sub
Err_exitloop_Click:
MsgBox Err.Description
Resume Exit_exitloop_Click
rsZips.Close
Set rsZips = Nothing
dbs.Close
Set dbs = Nothing
stationlen = Len(stationdesc)
Forms!frm_menu_item_setup!Station = Left(stationdesc, stationlen - 2)
End Sub
for set-up purposes... but I'd like the user to check boxes on the subform
and have a sentence show up on the main form in a field.
Example:
Station Use
Cheese x
Sauce
Chips x
Salsa
Sentence would look like: Cheese, Chips
My programming works, except I get an error because it can't go to specified
record when I am on the last record. For some reason - .movefirst and
..movenext don't want to work.
Here is my code. Thank you for any help! Tammy
Private Sub use_AfterUpdate()
Dim stationdesc As String
stationdesc = ""
Dim stationone As String
Dim dbs As DAO.Database
Dim rsZips As DAO.Recordset
Set dbs = CurrentDb
Set rsZips = dbs.OpenRecordset("tlist_station")
With rsZips
If .EOF = False And .BOF = False Then
'.MoveFirst
DoCmd.GoToRecord , , acFirst
Do While .EOF = False
stationone = IIf(Me!use = -1, Me!Station & ", ", "")
stationdesc = stationdesc & stationone
'.MoveNext
On Error GoTo Err_exitloop_Click
DoCmd.GoToRecord , , acNext
Loop
End If
End With
Exit_exitloop_Click:
rsZips.Close
Set rsZips = Nothing
dbs.Close
Set dbs = Nothing
stationlen = Len(stationdesc)
Forms!frm_menu_item_setup!Station = Left(stationdesc, stationlen - 2)
Exit Sub
Err_exitloop_Click:
MsgBox Err.Description
Resume Exit_exitloop_Click
rsZips.Close
Set rsZips = Nothing
dbs.Close
Set dbs = Nothing
stationlen = Len(stationdesc)
Forms!frm_menu_item_setup!Station = Left(stationdesc, stationlen - 2)
End Sub