Refering to fields on a continuous form

RT

Registered User.
Local time
Today, 02:28
Joined
May 30, 2002
Messages
10
How do you refer to a single field on a continuous form, as for example, if you have a 'client' text box, all records shown on the form will have a text box called client and any reference to client seems to be ambiguous.

Cheers

Rich
 
Where do you want to reference it, on the form in vba or in query criteria. Either use the Me keyword or the Forms! reference
HTH
 
To be more specific, I have written some VBA that validates a frequency field. The code is run before update of the field. However, if the user enters incorrect data, the error message pops up as many times aas there are records on the screen. I am only assuming this is due to the fact that all records have a 'frequency' field. My code is refering to the field specifically, using the Forms![form name]!Frequency method.
 
Private Sub FrequencyCheck()

Dim freq As String
Dim length As Integer
Dim ctrl As Control
Dim strSame

Set ctrl = Forms![Dispatches subform]!Frequency


If Not (IsNull(Forms![Dispatches subform]!Frequency)) Then

freq = Trim$(Forms![Dispatches subform]!Frequency)

If Len(freq) < 3 Then

chuckOut: MsgBox ("Months must be specified by their first 3 letters and seperated by spaces only")
DoCmd.CancelEvent
Exit Sub

ElseIf Len(freq) = 3 Then

checkLine: If ((freq Like "Jan") Or (freq Like "Feb") Or (freq Like "Mar") Or _
(freq Like "Apr") Or (freq Like "May") Or (freq Like "Jun") Or _
(freq Like "Jul") Or (freq Like "Aug") Or (freq Like "Sep") Or _
(freq Like "Oct") Or (freq Like "Nov") Or (freq Like "Dec")) Then

Exit Sub

Else

GoTo chuckOut

End If

End If

ifLine: If ((Left(freq, 4) Like "Jan ") Or (Left(freq, 4) Like "Feb ") _
Or (Left(freq, 4) Like "Mar ") Or (Left(freq, 4) Like "Apr ") _
Or (Left(freq, 4) Like "May ") Or (Left(freq, 4) Like "Jun ") _
Or (Left(freq, 4) Like "Jul ") Or (Left(freq, 4) Like "Aug ") _
Or (Left(freq, 4) Like "Sep ") Or (Left(freq, 4) Like "Oct ") _
Or (Left(freq, 4) Like "Nov ") Or (Left(freq, 4) Like "Dec ")) Then

length = Len(freq) - 4
freq = Trim(Right(freq, length))


If IsNull(freq) Then
Exit Sub
ElseIf Len(freq) < 3 Then
GoTo chuckOut
ElseIf Len(freq) = 3 Then
GoTo checkLine
Else
GoTo ifLine
End If

Else
GoTo chuckOut
End If

End If



End Sub
 
I've actually just realised that its giving the error message 3 times, so it's nothing to do with nameing the text box.
 
Not quite sure what your doing but why not force users to select frequency from a pre-defined combo box/ list?
 
because they need to be able to choose any number of options from the list.
 
If the combo box is on each of the subform entries, they can choose from the list each time, as many times as are needed. I think you're making this harder on yourself than it has to be.

There are ways to dynamically update the combo box list so they can only choose a certain entry off the list once per record, but that's a little more tricky.
 

Users who are viewing this thread

Back
Top Bottom