Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help: On open event(code)

Status
Not open for further replies.

vani65

Programmer
May 19, 2003
101
AU
Hi,

I have a form that should open blank but users should not enter anything in fields except the filter fields. When we move to next record it should be editable. I am using following code but still when form is opened users are able to enter. Could someone tell where I am doing wrong.
Thanks in advance

Form_open
'===================================================================================
' Default the filtering
'===================================================================================
cmdFilter.Caption = FILTER_ON_TEXT_G
ToggleFilter

'===================================================================================
' Go to the first record
'===================================================================================
If Not (Me.Recordset.BOF And Me.Recordset.EOF) Then Me.Recordset.MoveFirst

'===================================================================================
' Maximise Main form
'===================================================================================
DoCmd.Maximize
End Sub


Private Sub ToggleFilter()

On Error GoTo ToggleFilter_ERR

Dim strICPFilter As String
Dim strSQL As String

'===================================================================================
' Filter is already on - switch off
'===================================================================================
If cmdFilter.Caption = FILTER_ON_TEXT_G = True Then
Me.FilterOn = False
Me.Filter = ""
txtCurrentFilter = Me.Filter
cmdFilter.Caption = FILTER_OFF_TEXT_G
cmdFilter.SetFocus
txtFilterValue.Enabled = True
cmbFilterType.Enabled = True
txtFilterValue = ""
cmbFilterType = "ICP Number"
If Not (Me.Recordset.BOF And Me.Recordset.EOF) Then Me.Recordset.MoveFirst

'===================================================================================
' Filter is off - switch on
'===================================================================================
Else

'===================================================================================
' Get the value to Filter for
'===================================================================================
txtFilterValue.SetFocus
strICPFilter = Trim(txtFilterValue.Text)

'===================================================================================
' Ensure we have a Filter value
'===================================================================================
If Len(strICPFilter) = 0 Then
ReportErrorMessage "You must enter a value in the equals field in order to filter."
Exit Sub
End If

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top