I have a form that has to show an employee's work history details. There are many details it must display so it has a couple tabs on the form. The name of this form is "frmEmployeeWHInfo". To get to this form, the user double-clicks on an employee's name on ListBox control on a form called "frmShops". So upon double-clicking on the ListBox control, the function is run:
The reason I have the OpenArgs is because the Employee's Social Security number and the shop for which they work needs to be passed to the new form. The employee can work for multiple shops so that is why it is important.
Now that the double-click function is run the form "frmEmployeeWHInfo" is opened, and it runs the Form_Load function:
the ParseArgString function is:
In that form I have a bunch of text boxes that must display relevant information such as the employee's full name, SSN, hire date, transaction dates, billing status, fees, etc. This information is stored in different tables. How do I make the form display only the information that matches the employee's SSN and Shop they work for?
The tables I have are:
tblEmployees
-SSN
-LastName
-FirstName
-MiddleInitial
tblWorkHistory
-EmpSSN
-WHShopNumber
-WHTransactionDate
-WHHireDate
-WHBillingStatus
-WHFeesDue
So I would have to have the form find and display all of this information in appropriate text boxes on one form. I tried writing a query but I cannot get it to work.
qryEmpWH:
I need the query to show only values where "tblEmployees.SSN = tblWorkHistory.EmpSSN" AND where "tblWorkHistory.WHShopNumber = [Forms]![frmEmployeeWHInfo]![txtShopNum]"
Thanks in advance!
Code:
Private Sub lstEmployeeRoster_DblClick(Cancel As Integer)
Dim strEmpSSN As String
Dim strShopNum As Double
strEmpSSN = lstEmployeeRoster.Column(1)
strShopNum = Me.ShopNumber
DoCmd.OpenForm "frmEmployeeWHInfo", , , "SSN = '" & strEmpSSN & "'", , , "&EmpSSN=" & strEmpSSN & "&ShopNum=" & strShopNum
End Sub
The reason I have the OpenArgs is because the Employee's Social Security number and the shop for which they work needs to be passed to the new form. The employee can work for multiple shops so that is why it is important.
Now that the double-click function is run the form "frmEmployeeWHInfo" is opened, and it runs the Form_Load function:
Code:
Private Sub Form_Load()
Dim strEmpSSN As String
strEmpSSN = ParseArgString("EmpSSN", Me.OpenArgs)
txtEmpSSN.Caption = strEmpSSN
txtShopNum = ParseArgString("ShopNum", Me.OpenArgs)
txtSSN.SetFocus
txtSSN = strEmpSSN
End Sub
the ParseArgString function is:
Code:
Public Function ParseArgString(ByVal strKeyword As String, ByVal strArgString As String) As Variant
' argstring format:
' &keyword=value&keyword=value
' arg to this function should not include the &
On Error GoTo ErrorHandler
Dim intKeywordPos As Integer
Dim intNextKeyWordPos
If IsNull(strKeyword) Or IsNull(strArgString) Then
ParseArgString = Null
ElseIf Len(strKeyword) = 0 Or Len(strArgString) = 0 Then
ParseArgString = Null
Else
intKeywordPos = InStr(1, strArgString, "&" & strKeyword, vbTextCompare)
If IsNull(intKeywordPos) Or intKeywordPos = 0 Then
ParseArgString = Null
Else
intNextKeyWordPos = InStr(intKeywordPos + 1, strArgString, "&", vbTextCompare)
If intNextKeyWordPos = 0 Then
intNextKeyWordPos = Len(strArgString) + 1
End If
ParseArgString = Mid(strArgString, intKeywordPos + Len(strKeyword) + 2, _
intNextKeyWordPos - (intKeywordPos + Len(strKeyword) + 2))
End If
End If
ExitSub:
Exit Function
ErrorHandler:
On Error Resume Next
Debug.Print "ParseArgString encountered error " & Err.Number & " " & Err.Description
GoTo ExitSub
End Function
In that form I have a bunch of text boxes that must display relevant information such as the employee's full name, SSN, hire date, transaction dates, billing status, fees, etc. This information is stored in different tables. How do I make the form display only the information that matches the employee's SSN and Shop they work for?
The tables I have are:
tblEmployees
-SSN
-LastName
-FirstName
-MiddleInitial
tblWorkHistory
-EmpSSN
-WHShopNumber
-WHTransactionDate
-WHHireDate
-WHBillingStatus
-WHFeesDue
So I would have to have the form find and display all of this information in appropriate text boxes on one form. I tried writing a query but I cannot get it to work.
qryEmpWH:
Code:
SELECT tblWorkHistory.WHShopNumber, tblWorkHistory.WHTransactionDate
FROM tblBillingBalance, tblBillingHistory, tblWorkHistoryPlan, tblEmployees INNER JOIN tblWorkHistory ON tblEmployees.SSN = tblWorkHistory.EmpSSN
WHERE (((tblWorkHistory.WHShopNumber)=[Forms]![frmEmployeeWHInfo]![txtShopNum]));
I need the query to show only values where "tblEmployees.SSN = tblWorkHistory.EmpSSN" AND where "tblWorkHistory.WHShopNumber = [Forms]![frmEmployeeWHInfo]![txtShopNum]"
Thanks in advance!