Results 1 to 2 of 2
  1. #1
    access.newby is offline Novice
    Windows XP Access 2002
    Join Date
    Nov 2009
    Posts
    1

    Question Help with VBA Code

    Hi, this is my first post so I hope you can help. The crux of what I need to do in VBA is loop through all the records in a table (tblDetail), when a control break is reached (ie Client and Day change) then reset a counter to 1 otherwise add 1. The other complication is that tblHeader has a selection criteria I need to use. I have very minimal exposure to DAO coding so I may need a lot of help. Here are my table relationships:

    tblHeader (660 records)
    RunID autonumber (PK)
    RunCode text*10 (Index with dups
    Roster_Code text*25(lookup)
    Week_Day integer(lookup)
    Staff_No integer(lookup)
    RunStartTime date
    IncludeInRoster yes/no

    tblDetail (1170 records)
    ID autonumber(PK)
    RunID number(lookup)
    Client_No integer(lookup)
    Roster_Type text*1(N,C,R)
    FundingSource text*4(lookup)
    Duration date(time)
    Start_Time date(time)
    End_Time date(time)
    Travel_Time date(time)
    VisitNo integer <<<This is the important value, 1=First visit, 2=2nd visit etc) for a Client on a given day

    The metacode would be something like:

    Open the tables (tblDetail for updating)
    Set tmpVisitNo=0
    Select only records From tblHeader where IncludeInRoster = yes
    Sort the records in tblDetail by Client_no, then Week_Day(from tblHeader)
    Loop through the records
    when the Client/Day change reset tmpVisitNo to 1
    otherwise add 1 tmpVisitNo, update VisitNo with tmpVisitNo



    I know this is a big ask but I am desperate here

  2. #2
    Max D's Avatar
    Max D is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jul 2009
    Posts
    63
    There are several ways to do this, but its obvious you don't need such a VisitNo really.
    Once you need some sort of data, you can get it from database with queries.

    Try to describe the situation when you are going to use that VisitNo and I'm sure there is a nice query to do the thing.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Help with vba code
    By rockape in forum Programming
    Replies: 11
    Last Post: 09-29-2009, 06:49 AM
  2. Code Trouble?
    By briancb2004 in forum Access
    Replies: 0
    Last Post: 10-08-2008, 04:47 PM
  3. Need help with code
    By hoenheim in forum Programming
    Replies: 9
    Last Post: 09-11-2008, 04:19 PM
  4. Need Help Getting to Code
    By Snuffles in forum Programming
    Replies: 8
    Last Post: 04-22-2008, 05:25 PM
  5. Navigation Code
    By henryclay in forum Forms
    Replies: 2
    Last Post: 11-15-2006, 09:48 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums