Computing.Net > Forums > Programming > Coding Error

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Coding Error

Reply to Message Icon

Name: Eliza1234
Date: March 16, 2009 at 19:03:25 Pacific
OS: Windows XP
Subcategory: C/C++
Comment:

For the view All, it's able to run perfect, but when it comes to choosing other variable besides View All, have error instead. I try to solve it since last week. Please Help! Thanks!


Private Sub Command10_Click()
'initalise variable
'categorise FormSelection into variable choice

Dim choice As String
If (FormSelection.Value = "Vendor") Then
choice = "A"
ElseIf (FormSelection.Value = "Inhouse") Then
choice = "B"
ElseIf (FormSelection.Value = "Japan") Then
choice = "C"
End If

On Error GoTo Err_Command10_Click

Dim stDocName As String

stDocName = "ProductRpt"

'>> Total of 4 combinations <<
'Category Name = view all Form Selection = view all
If (CateName.Value = "View All" And FormSelection.Value = "View All") Then
DoCmd.OpenReport stDocName, acPreview

'Category Name = view all Form Selection != view all
ElseIf (CateName.Value = "View All" And FormSelection.Value <> "View All") Then
DoCmd.OpenReport stDocName, acPreview, , "FormSelection = " & choice

'Category Name != view all Form Selection = view all
ElseIf (CateName.Value <> "View All" And FormSelection.Value = "View All") Then

'Category Name! = view all Form Selection != view all
DoCmd.OpenReport stDocName, acPreview, , "CateName =" & CateName.Value
Else

'rest is team and criteria
DoCmd.OpenReport stDocName, acPreview, , "CateName = '" & CateName.Value & _
"' and FormSelection = " & choice
End If
Exit_Command10_Click:
Exit Sub

Err_Command10_Click:
MsgBox Err.Description
Resume Exit_Command10_Click

End Sub

Private Sub FormSelection_AfterUpdate()

'not one of the choice in DDL
'not view not outstanding not completed
If (FormSelection.Value = "View all") Then
ElseIf (FormSelection.Value = "Vendor") Then
ElseIf (FormSelection.Value = "Inhouse") Then
ElseIf (FormSelection.Value = "Japan") Then
Else
FormSelection.Value = "View all"
End If
End Sub



Sponsored Link
Ads by Google

Response Number 1
Name: Razor2.3
Date: March 16, 2009 at 20:10:34 Pacific
Reply:

Try this:

DoCmd.OpenReport stDocName, acPreview, , "CateName = '" & CateName.Value & "'"


0

Response Number 2
Name: Eliza1234
Date: March 16, 2009 at 21:06:10 Pacific
Reply:

It is still the same. When run, i choose in a different variable that is provided in the drop down list, it shows all the records but not the specific record i want. Also, it keep poping out a Msg box with a heading saying" parameter value" And i've to key in something before it can proceed to showing the record. Thanks btw. (:


0

Response Number 3
Name: reno
Date: March 16, 2009 at 21:31:16 Pacific
Reply:

dim choice as string
......
'Category Name = view all Form Selection != view all
ElseIf (CateName.Value = "View All" And FormSelection.Value <> "View All") Then
DoCmd.OpenReport stDocName, acPreview, , "FormSelection = " & choice

choice is of string datatype, when filtering, you have to put quotes around any string:
DoCmd.OpenReport stDocName, acPreview, , "FormSelection = """ & choice & """"

and what happened if choice is null/empty??


0

Response Number 4
Name: Eliza1234
Date: March 16, 2009 at 22:39:09 Pacific
Reply:

Thanks so much for the reply. I implement the coding you gave me and made amendments. But still, when changing the variables for CateName, and FormSelection View All, it shows all the records regardless it is relevant or not.

When i change variables for FormSelection and CatName stick with View All, no record was shown.

If choice is nothing, there would be an error?


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


VB script to put time and... Folder Name & Number of F...



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Coding Error

Batch code error www.computing.net/answers/programming/batch-code-error/18959.html

Error Message on webpage: validated www.computing.net/answers/programming/error-message-on-webpage-validated/15444.html

Error during compilation www.computing.net/answers/programming/error-during-compilation/10217.html