Not Really Sure

  • Thread starter Thread starter Afrosheen
  • Start date Start date
A

Afrosheen

First of all, thanks for reading my question.

I have a combo box called [shift]. Part of the combo infomation is either
A-Days or B-Days. These are rotations. So you have to select either one. Once
selected it will come up with the correct information. Now here is what I
want to do.

I want to take the information and store it probably to a string. If I
change the combo box infomation, then when I click on my "Save Record"
Command it will check to see if the information in the combo box is the same
information as the stored string. If it is then exit. If not then it requery
the form and set it on the proper rotation. I don't need it to requery every
single time I click on the check box. Just when the [shift] information
changes. I hope I've explained my self correctly.

Here is part of the program:

Private Sub cmdSave_Click()
10 On Error GoTo Err_cmdSave_Click
11 Dim lngpos As Integer
12 lngpos = Me.Recordset.AbsolutePosition

20 DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, ,
acMenuVer70
30 DoCmd.OpenForm "frmubeensaved", acNormal, "", "", acReadOnly,
acNormal
40 DoCmd.RepaintObject acForm, "frmubeensaved"

45 Forms!frm_roster.Requery
48 Me.Recordset.AbsolutePosition = lngpos

Exit_cmdSsave_Click:
50 Exit Sub

Err_cmdSave_Click:
60 Call LogError(Err.Number, Err.Description, "cmdsave_click()")
70 Resume Exit_cmdSsave_Click

End Sub
 
Hi Afrosheen,
most form controls have a tag property you can use to do this type of thing.

After the user makes a choice from the combo, you save the value of the
combo in the combo's tag.

Private Sub Shift_AfterUpdate()
Me.Shift.Tag = Nz(Me.Shift,"")
End Sub

Your code would be something like this:
(warning - untested air code)

Private Sub cmdSave_Click()
10 On Error GoTo Err_cmdSave_Click
11 Dim lngpos As Integer
12 lngpos = Me.Recordset.AbsolutePosition
'save the record
20 If Me.Dirty = True Then
Me.Dirty = False
End If
30 DoCmd.OpenForm "frmubeensaved", acNormal, "", "", acReadOnly,
acNormal
40 DoCmd.RepaintObject acForm, "frmubeensaved"
'now check the combo
If Me.Shift.Tag = Me.Shift Then
'can close the form
DoCmd.Close acForm, Me.Name
Else
Me.Requery
48 Me.Recordset.AbsolutePosition = lngpos
End If
Exit_cmdSsave_Click:
50 Exit Sub

Err_cmdSave_Click:
60 Call LogError(Err.Number, Err.Description, "cmdsave_click()")
70 Resume Exit_cmdSsave_Click

End Sub


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia


Afrosheen said:
First of all, thanks for reading my question.

I have a combo box called [shift]. Part of the combo infomation is either
A-Days or B-Days. These are rotations. So you have to select either one.
Once
selected it will come up with the correct information. Now here is what I
want to do.

I want to take the information and store it probably to a string. If I
change the combo box infomation, then when I click on my "Save Record"
Command it will check to see if the information in the combo box is the
same
information as the stored string. If it is then exit. If not then it
requery
the form and set it on the proper rotation. I don't need it to requery
every
single time I click on the check box. Just when the [shift] information
changes. I hope I've explained my self correctly.

Here is part of the program:

Private Sub cmdSave_Click()
10 On Error GoTo Err_cmdSave_Click
11 Dim lngpos As Integer
12 lngpos = Me.Recordset.AbsolutePosition

20 DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, ,
acMenuVer70
30 DoCmd.OpenForm "frmubeensaved", acNormal, "", "", acReadOnly,
acNormal
40 DoCmd.RepaintObject acForm, "frmubeensaved"

45 Forms!frm_roster.Requery
48 Me.Recordset.AbsolutePosition = lngpos

Exit_cmdSsave_Click:
50 Exit Sub

Err_cmdSave_Click:
60 Call LogError(Err.Number, Err.Description, "cmdsave_click()")
70 Resume Exit_cmdSsave_Click

End Sub
 
Back
Top