Hello all,
Thank you in advance for your help. I am a very low level access user that mostly dabbles, so I apologize for anything that might be frowned upon. I mostly pick up code from these forums and try to make them work for me. I have the following code that is giving me a data type mismatch error:
Private Sub SubClassNumber_AfterUpdate()
Dim strSQL As String
Dim rst As DAO.Recordset
strSQL = " SELECT ClassDescription " & _
"FROM tblClassAll " & _
"WHERE SubClassNumber = " & Me.SubClassNumber.Value & "" _
And ClassNumber = " & Me.ClassNumber.Value & " _
And DepartmentNumber = " & Me.DepartmentNumber.Value & "
Set rst = CurrentDb.OpenRecordset(strSQL, dbOpenSnapshot)
Me.ClassDescription.Value = rst!ClassDescription
rst.Close
Set rst = Nothing
End Sub
Long and short... I am trying to autopopulate the ClassDescriptionField (text), based upon the selections made under DepartmentNumber (number), ClassNumber (number), and SubClassNumber (number). All of these fields reside on the same table tblClassAll. tblClassAll is simply a record source table listing all of the different Departments, Classes, Sub Classes and Class Descriptions. The form does not update tblClassAll, it updates a table called tblOrderInfo, which has all of the fields referenced under tblClassAll plus some other fields.
To probably further complicate things, the DepartmentNumber, ClassNumber and SubClassNumber fields in the form are cascading combo boxes, so as to limit the selections under ClassNumber depending upon the DepartmentNumber selected, and to limit the SubClassNumber selections depending upon the ClassNumber selected.
At the end of the day I want the person to select the Department, and only be given Class numbers under that Department. Then select the Class number and only be given the Sub Class Numbers under that Department and Class. Then select the Sub Class Number and have the Class Description autopopulate based on all three selections. I already have the cascading feature working, just need that last part.
If I have not provided adequate information please let me know what you need, and I can supply. Thanks!