Filtering...I think

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I posted this question in another forum and no one answered. So I'm posting
it here because maybe I posted it in the wrong forum.

Hello,

I have the following code. What I want is for when the user selects the
region from cboREGION, enter's the password, and clicks the GO button, I want
the frmENTER_LEAK_FORM to only display the communities that are in the
specified Region which was selected in the previous form (frmRegions) from
cboREGION. REGION in the other form is just a text field, and it doesn't
seem to be doing anything. There is a list box that has two colums,
communities and region. I have the basics, but I don't have the filtering
part. How would I do this?

Private Sub cmdLogin_Click()

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmENTER_LEAK_FORM"

stLinkCriteria = "[REGION]=" & "'" & Me![cboREGION] & "'"

'Check to see if data is entered into the UserName combo box

If IsNull(Me.cboREGION) Or Me.cboREGION = "" Then
MsgBox "You must enter a Region.", vbOKOnly, "Required Data"
Me.cboREGION.SetFocus
Exit Sub
End If

'Check to see if data is entered into the password box

If IsNull(Me.txtPassword) Or Me.txtPassword = "" Then
MsgBox "You must enter a Password.", vbOKOnly, "Required Data"
Me.txtPassword.SetFocus
Exit Sub
End If

'Check value of password in tblRegions to see if this matches value chose in
combo box

If Me.txtPassword.Value = DLookup("strRegPassword", "tblRegions",
"[lngRegID]=" & Me.cboREGION.Value) Then
lngMyRegID = Me.cboREGION.Value

'Close logon form and open enter leak form

DoCmd.Close acForm, "frmSELECT_REGION", acSaveNo
DoCmd.OpenForm stDocName, , , stLinkCriteria

Else
MsgBox "Password Invalid. Please Try Again", vbOKOnly, "Invalid Entry!"
Me.txtPassword.SetFocus
End If

'If User Enters incorrect password 3 times the database will shut down

intLogonAttempts = intLogonAttempts + 1
If intLogonAttempts > 3 Then
MsgBox "You do not have access to this database.Please contact the Databas
Administrator.", vbCritical, "Restricted Access!"
Application.Quit
End If

Exit_cmdLogin_Click:
Exit Sub

Err_cmdLogin_Click:
MsgBox Err.Description
Resume Exit_cmdLogin_Click

End Sub
 
'Close logon form and open enter leak form

DoCmd.Close acForm, "frmSELECT_REGION", acSaveNo
DoCmd.OpenForm stDocName, , , stLinkCriteria

Flip flop these two lines in your code. See if that helps.
 
Jeff,

Thanks for your suggestion, but that didn't work. Any other ideas?
 
What is happening when you open the other form? What isn't working
properly?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top