
Originally Posted by
June7
I suggest the combobox GotFocus event in case user changes value of Text6. The form Current event won't accommodate that occurrence.
However, if user changes Text6, should the data in the combobox field be deleted so user must select another value associated with the new value in Text6?
Ok, am I doing this all wrong? See really Text6 is just a hidden field because I was playing around and I couldn't get the value that is assigned to it in query to make it work correctly. I put it in Text6 to see if it was coming in correctly, which it is.
Here is my frmLogin code, this is the 1st screen where they log in. Depending on who is logging in I need to display a "Group" number they can pick from. Then depending on which "Group" they pick I need to display the "questions" in the detail section for that particular group. (Along with the questions they will have an edit and delete next to the questions so they can maintain the questions and answers.)
Code:
Option Compare Database
Dim intLogonAttempts As Integer
Private Sub Form_Load()
Me.cboDept.SetFocus
Me.cboDept = Null
Me.txtPassword = Null
End Sub
Private Sub cmdLogin_Click()
'Check that Dept is selected
If IsNull(Me.cboDept) Then
MsgBox "You must enter a Department Name.", vbCritical
Me.cboDept.SetFocus
Else
'Check for correct password
If Me.txtPassword.Value = DLookup("pwPW", "faqPW", "[pwPKID]=" & Me.cboDept.Value) Then
lngPKID = DLookup("pwPKID", "faqPW", "[pwPKID]=" & Me.cboDept.Value)
DoCmd.OpenForm "frmQA"
Me.Visible = False
Else
MsgBox "Password Invalid. Please Try Again", vbOKOnly, "Invalid Entry!"
Me.txtPassword = Null
Me.txtPassword.SetFocus
End If
End If
'If User Enters incorrect password 3 times database will shutdown
intLogonAttempts = intLogonAttempts + 1
If intLogonAttempts > 3 Then
MsgBox "You do not have access to this database. Please contact your system administrator.", vbCritical, "Restricted Access!"
Application.Quit
End If
End Sub
Here is the code in my frmQA.
Code:
Option Compare Database
Private Sub cboGroup_GotFocus()
cboGROUP.RowSource = "SELECT DISTINCT faqQA.qaGROUP FROM faqQA WHERE fkPWPKID = Text6.Value ORDER BY faqQA.qaGROUP"
End Sub
Private Sub Form_Load()
Text6.Value = lngPKID
'cboGROUP.RowSource = "SELECT DISTINCT faqQA.qaGROUP FROM faqQA ORDER BY faqQA.qaGROUP"
'cboGROUP.RowSource = "SELECT DISTINCT faqQA.qaPKID, faqQA.qaGROUP FROM faqQA WHERE fkPWPKID = Text6.Value ORDER BY faqQA.qaGROUP"
cboGROUP.RowSource = "SELECT DISTINCT faqQA.qaGROUP FROM faqQA WHERE fkPWPKID = Text6.Value ORDER BY faqQA.qaGROUP"
Me.cboGROUP.SetFocus
End Sub
The field "lngPKID" is defined in a module so that all forms will have access to it.
Here are my tables in case you need them to understand. The departments can have many groups, the sort is just used to put the questions in order.
And just to make it even clearer I will attach my mock up. On my 2nd page though the drop down box says "Select FAQ Number", that is really "Group".
I have the drop down, the add question and the exit all in my header. I was going to put the questions with the edit buttons in the detail section. I haven't gotten that far yet. I am just at the point of making sure the drop down works. (Note: I am a bit confused on how to do the detail section. I was hoping to figure it out.)
I just wanted to get the drop down to work correctly before going any farther.
I haven't done access in many years and this is a lot harder than I had thought. I keep looking things up and it has gotten me this far but I am stuck.