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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with a VB query form

Status
Not open for further replies.

SuePee

Technical User
Jun 10, 2003
47
US
I have a database that keeps track of who completed which training and when it is due to be refreshed, etc, etc. Previously, the Cross Tab report was separated by department (Dept) now I want to sort it by Supervisor Code (Code). I copied the code and made the changes so that it related to my database for the department. One other thing is that the previous code allowed the person doing the input to skip the letter "L" which is the first part of the department. I have never taken a Visual Basic course, but I have managed to understand some of it. The first statement in the code says basically that it allows the "L" to be omitted. I changed the code to accept my reports but when I remove the first line it won't work. Please help me to make thos work and more importantly, to understand it. Also, What does the statement Me! mean?

Thanks for your help, now and in the past.

Sue

I am including the code for your perusal.
This is the code I copied.

Private Sub Command0_Click()
If UCase(Left(Me![Report_Dept], 1)) <> "L" Then
If Me!Report_Type = 1 Then
DoCmd.OpenReport "X_ByDept_Emp_Req", acViewPreview, , "[dept] = " & Chr(34) & "L" & Me![Report_Dept] & Chr(34)
Else
DoCmd.OpenReport "X_Req/Comp", acViewPreview, , "[dept] = " & Chr(34) & "L" & Me![Report_Dept] & Chr(34)
End If
Else
If Me!Report_Type = 1 Then
DoCmd.OpenReport "X_ByDept_Emp_Req", acViewPreview, , "[dept] = " & Chr(34) & Me![Report_Dept] & Chr(34)
Else
DoCmd.OpenReport "X_Req/Comp", acViewPreview, , "[dept] = " & Chr(34) & Me![Report_Dept] & Chr(34)
End If
End If
End Sub

This is how I changed it, but it won't work. I changed the report name (The report works fine, but is for the whole shop) And I change the Report_Dept to Report_Code.

Private Sub Command0_Click()
If UCase(Me![Report_Code], 1)) <> "C" Then
If Me!Report_Type = 1 Then
DoCmd.OpenReport "X_BySuper_Emp_Req", acViewPreview, , "
Code:
 = " & Chr(34) & "L" & Me![Report_Code] & Chr(34)
            Else
                DoCmd.OpenReport "X_Req/Comp/s", acViewPreview, , "[code] = " & Chr(34) & "L" & Me![Report_Code] & Chr(34)
            End If
        Else
        If Me!Report_Type = 1 Then
                DoCmd.OpenReport "X_BySuper_Emp_Req", acViewPreview, , "[code] = " & Chr(34) & Me![Report_Code] & Chr(34)
            Else
                DoCmd.OpenReport "X_Req/Comp/s", acViewPreview, , "[code] = " & Chr(34) & Me![Report_Code] & Chr(34)
            End If
        End If
End Sub


Same Circus, Different Clowns
 
In the second line of your code you have "C" - should this still be "L" ?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top