Computing.Net > Forums > Programming > VBA Access 2003

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.

VBA Access 2003

Reply to Message Icon

Name: Eliza1234
Date: March 19, 2009 at 18:17:11 Pacific
OS: Windows XP
Subcategory: C/C++
Comment:

I didn't know where went wrong. When i select View All in both the combo box, it appear the data that i want. Yet if when i change the variable of the CateName and View All in the FormSelection, the data appear all, which is not what i need. Anyone can tell me where when wrong?

Option Compare Database
Option Explicit

Private Sub Command10_Click()
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 CateName and FormSelection
DoCmd.OpenReport stDocName, acPreview, , "CateName ='" & CateName.Value & _
"' 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: reno
Date: March 19, 2009 at 22:20:40 Pacific
Reply:

is it "View all" or "View All"???


0

Response Number 2
Name: Eliza1234
Date: March 19, 2009 at 22:26:40 Pacific
Reply:

View All.
I've solved the top of the error alr. Would you mind seeing if
these coding got error?

DoCmd.OpenReport stDocName, acPreview, , "ProductCat ='" & ProductCat.Value & _
"FormSelection ='" & FormSelection.Value & "'"

Becos it keep saying Syntax Error(missing operator) in query expression

Thanks for your reply btw. (:


0

Response Number 3
Name: Razor2.3
Date: March 19, 2009 at 22:38:20 Pacific
Reply:

"ProductCat ='" & ProductCat.Value & _
"FormSelection ='"

You never close your single quote.

0

Response Number 4
Name: Eliza1234
Date: March 19, 2009 at 22:50:41 Pacific
Reply:

"ProductCat ='" & ProductCat.Value & "'"_
"FormSelection ='" & FormSelection.Value & "'"

Like that?


0

Response Number 5
Name: Razor2.3
Date: March 19, 2009 at 23:16:19 Pacific
Reply:

That would do it, but you also need some sort of relation between the two conditional statements.

"ProductCat ='" & ProductCat.Value _
"' AND FormSelection ='" & FormSelection.Value & "'"


0

Related Posts

See More



Response Number 6
Name: Eliza1234
Date: March 19, 2009 at 23:23:10 Pacific
Reply:

It Works!! Thanks!! :D


0

Sponsored Link
Ads by Google
Reply to Message Icon






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: VBA Access 2003

Access 2003 & query parameters www.computing.net/answers/programming/access-2003-amp-query-parameters/12931.html

How to do a FindFirst in VBA-Access www.computing.net/answers/programming/how-to-do-a-findfirst-in-vbaaccess/3174.html

Strange Access 2003 Problem www.computing.net/answers/programming/strange-access-2003-problem/10649.html