M.L. Sco Scofield said:
With the information you provided, the line is just fine.
We're going to need more information to help you.
The best piece of information would be what you mean by "...failing..."
Are you getting an error message? If this is a code line, is it red? Does
your code compile?
Another piece of information that might be nice is where is this line?
What is "Holder"? A text box? A variable? If so, what type?
<<SNIP>>
The problem I'm trying to address is : I have criteria that will change the
value of a text box on the form AND the same criteria restricts user
navigation through the form.
I'm attempting to write a case select procedure for a form to restrict
user movement within the table. 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.
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.
The code fails when the form is opened by another form and the editor
highlights the line
"Holder = Forms!vForm!Placeholder.Value" in yellow.
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.
The code is attached to the Form's "On Update" event?
If there's a better way to do this please advise the general concept and
I'll get to reading.
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