Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 7th, 2005, 12:50 PM
Authorized User
 
Join Date: Dec 2004
Location: Belfast, Antrim, United Kingdom.
Posts: 43
Thanks: 0
Thanked 0 Times in 0 Posts
Default case statement

Hi

I am trying to compare two tables,an input table and a master table. I am trying to compare the variables vAccNumber1,vAccNumber2,vAccNumber3 and vAccNumber4 appearing in the input table (tbl1) with vAccNumber1b,vAccNumber2b, vAccNumber3b, vAccNumber4b appearing in the master table (tbl2). If there is a match I call another function. However I also need another condition that the variables vAccNumber1,vAccNumber2,vAccNumber3 and vAccNumber4 are more than zero. I don't want the function called if a match of two zeros is found. I have tried to put if statemnts within the select cases but access doesn't like this. Anyone any ideas?

Here's the code:

Do Until tbl1.EOF
    vAccNumber1 = tbl1![AccountNumber1]
    vAccNumber2 = tbl1![AccountNumber2]
    vAccNumber3 = tbl1![AccountNumber3]
    vAccNumber4 = tbl1![AccountNumber4]


        Do Until tbl2.EOF
            vAccNumber1b = tbl2![AccountNumber1]
            vAccNumber2b = tbl2![AccountNumber2]
            vAccNumber3b = tbl2![AccountNumber3]
            vAccNumber4b = tbl2![AccountNumber4]

            Select Case vAccNumber1

                Case vAccNumber1b
                    Call bob
                    Exit Sub
                Case vAccNumber2b
                    Call bob
                    Exit Sub
                Case vAccNumber3b
                    Call bob
                    Exit Sub
                Case vAccNumber4b
                    Call bob
                    Exit Sub
                Case Else


            Select Case vAccNumber2

                Case vAccNumber1b
                    Call bob
                    Exit Sub
                Case vAccNumber2b
                    Call bob
                    Exit Sub
                Case vAccNumber3b
                    Call bob
                    Exit Sub
                Case vAccNumber4b
                    Call bob
                    Exit Sub
                Case Else


            Select Case vAccNumber3

                Case vAccNumber1b
                    Call bob
                    Exit Sub
                Case vAccNumber2b
                    Call bob
                    Exit Sub
                Case vAccNumber3b
                    Call bob
                    Exit Sub
                Case vAccNumber4b
                    Call bob
                    Exit Sub
                Case Else


            Select Case vAccNumber4

                Case vAccNumber1b
                    Call bob
                    Exit Sub
                Case vAccNumber2b
                    Call bob
                    Exit Sub
                Case vAccNumber3b
                    Call bob
                    Exit Sub
                Case vAccNumber4b
                    Call bob
                    Exit Sub
                Case Else

                    tbl2.MoveNext
            End Select
            End Select
            End Select
            End Select
        Loop
        tbl1.MoveNext
        tbl2.MoveFirst
Loop



Cheers
Tony
__________________
Cheers
Tony
Reply With Quote
  #2 (permalink)  
Old February 11th, 2005, 11:31 AM
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2004
Location: Washington, DC, USA.
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

I would need more information, but you can do this.

Why is there a table with fields named [AccountNumber1], [AccountNumber2], [AccountNumber3], and [AccountNumber4]?

This is not normalized data. Is this a strictly OLAP database, or are you managing transactions as well (OLTP)? If there is any transaction processing going on, then this structure needs to be changed.

You shouldn't have this sort of record:

CustomerID
FirstName: John
LastName: Doe
AccountNumber1: XXXXXXXXXX
AccountNumber2: ""
AccountNumber3: ""
AccountNumber4: ""

   You should always build for n accounts. So Accounts should be in a seperate table. This is why you have to loop through everything to compare account numbers.

It should look like this:

tblCustomer
CustomerID = PK
FirstName
LastName

tblAccounts
AccountID = PK
CustomerID = FK
Account Number

   Then each customer or whomever can have one account, or a thousand accounts.

Anywho, if you explain the structure you do have, I could help write the code to do this.



mmcdonal
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Case statement cole SQL Language 3 May 8th, 2005 03:02 PM
case statement troubles!! ronny Classic ASP Databases 2 April 10th, 2004 07:32 PM
Using A CASE Statement fastcorvette Access 5 December 24th, 2003 01:39 PM
HELP - IF ELSE & CASE statement savoym SQL Language 3 September 12th, 2003 06:35 AM
case statement jakeone Beginning PHP 10 August 19th, 2003 03:03 PM



All times are GMT -4. The time now is 05:54 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.