M
M Davidson
Hello All,
I'm attempting to write a case select procedure for a form to restrict
user movement within the table (recordset? (still trying to learn
terminology)). Depending on what criteria are met I want to enable/disable
the record navigation buttons. In addition, the same criteria will also
change the value of a text box control on the same form. It appears that
I'm not assigning my variables correctly, but I'm not sure.
DoCmd.GoToRecord , , acNewRec
Key.value is the serial number for the table tblScores. This is the same
table that the form's record source is assigned. So Key.value will be the
serial number on the current record being edited/entered. I used
DoCmd.GoToRecord , , acNewRec assigned to the form's open event to ensure
that the form opened on a new record.
Placeholder.value is a number that is assigned to an unbound control on an
unbound form called vForm. This is intended to be a hidden form to hold
variables for use at run time. I assigned the value to Placeholder.value by
using the domain aggregate function dLast to pull the last serial number
used to enter data prior to the current instance of frmScores being opened.
I want the user to be able to go forward and backwards through the records
he is currently entering, but I don't want him to be able to go back beyond
them or before them. The example below is intended to allow the user to
enter 5 scores only and force the change of category in txtCategory.value
on each record change. Once the user gets to the 5th record he can only go
back to edit or click the btnFinished button, which opens a completely
seperate form attached to another table.
another thing, I thought this one up on my own ( the navigation on math from
the serial number), so there's a real good possibility that the whole
concept is flawed. If it is let me know. Or if there's a better way...
Another thing: Should the code be attached to the Form's "On Update" event?
Heres's the code:
Dim Number
Dim Holder
'assign current record's serial number to Number
Number = Me!Key.Value
'assign last serial number from the previous set of 5 scores
(Placeholder.value) to Holder
Holder = Forms!vForm!Placeholder.Value
Select Case Number
Case Holder 'this is equal to the last record already entered
Me!btnBack.Enabled = No
Me!btnFinished.Enabled = No
Me!btnForward.Enabled = Yes
Me!txtCategory.Value = Something's wrong
'First record in set
Case Holder + 1
Me!btnBack.Enabled = No
Me!btnFinished.Enabled = No
Me!btnForward.Enabled = Yes
Me!txtCategory.Value = Cat1
'Second record in set
Case Holder + 2
Me!btnBack.Enabled = No
Me!btnFinished.Enabled = No
Me!btnForward.Enabled = Yes
Me!txtCategory.Value = Cat2
Case Holder + 3
Me!btnBack.Enabled = Yes
Me!btnFinished.Enabled = No
Me!btnForward.Enabled = Yes
Me!txtCategory.Value = Cat3
Case Holder + 4
Me!btnBack.Enabled = Yes
Me!btnFinished.Enabled = No
Me!btnForward.Enabled = Yes
Me!txtCategory.Value = Cat4
Case Holder + 5
Me!btnBack.Enabled = Yes
Me!btnFinished.Enabled = Yes
Me!btnForward.Enabled = No
Me!txtCategory.Value = Cat5
Case Else
Debug.Print "Value not represented."
End Select
I'm attempting to write a case select procedure for a form to restrict
user movement within the table (recordset? (still trying to learn
terminology)). Depending on what criteria are met I want to enable/disable
the record navigation buttons. In addition, the same criteria will also
change the value of a text box control on the same form. It appears that
I'm not assigning my variables correctly, but I'm not sure.
DoCmd.GoToRecord , , acNewRec
Key.value is the serial number for the table tblScores. This is the same
table that the form's record source is assigned. So Key.value will be the
serial number on the current record being edited/entered. I used
DoCmd.GoToRecord , , acNewRec assigned to the form's open event to ensure
that the form opened on a new record.
Placeholder.value is a number that is assigned to an unbound control on an
unbound form called vForm. This is intended to be a hidden form to hold
variables for use at run time. I assigned the value to Placeholder.value by
using the domain aggregate function dLast to pull the last serial number
used to enter data prior to the current instance of frmScores being opened.
I want the user to be able to go forward and backwards through the records
he is currently entering, but I don't want him to be able to go back beyond
them or before them. The example below is intended to allow the user to
enter 5 scores only and force the change of category in txtCategory.value
on each record change. Once the user gets to the 5th record he can only go
back to edit or click the btnFinished button, which opens a completely
seperate form attached to another table.
another thing, I thought this one up on my own ( the navigation on math from
the serial number), so there's a real good possibility that the whole
concept is flawed. If it is let me know. Or if there's a better way...
Another thing: Should the code be attached to the Form's "On Update" event?
Heres's the code:
Dim Number
Dim Holder
'assign current record's serial number to Number
Number = Me!Key.Value
'assign last serial number from the previous set of 5 scores
(Placeholder.value) to Holder
Holder = Forms!vForm!Placeholder.Value
Select Case Number
Case Holder 'this is equal to the last record already entered
Me!btnBack.Enabled = No
Me!btnFinished.Enabled = No
Me!btnForward.Enabled = Yes
Me!txtCategory.Value = Something's wrong
'First record in set
Case Holder + 1
Me!btnBack.Enabled = No
Me!btnFinished.Enabled = No
Me!btnForward.Enabled = Yes
Me!txtCategory.Value = Cat1
'Second record in set
Case Holder + 2
Me!btnBack.Enabled = No
Me!btnFinished.Enabled = No
Me!btnForward.Enabled = Yes
Me!txtCategory.Value = Cat2
Case Holder + 3
Me!btnBack.Enabled = Yes
Me!btnFinished.Enabled = No
Me!btnForward.Enabled = Yes
Me!txtCategory.Value = Cat3
Case Holder + 4
Me!btnBack.Enabled = Yes
Me!btnFinished.Enabled = No
Me!btnForward.Enabled = Yes
Me!txtCategory.Value = Cat4
Case Holder + 5
Me!btnBack.Enabled = Yes
Me!btnFinished.Enabled = Yes
Me!btnForward.Enabled = No
Me!txtCategory.Value = Cat5
Case Else
Debug.Print "Value not represented."
End Select