Results 1 to 5 of 5
  1. #1
    learmanj is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    Jul 2013
    Posts
    8

    How do I auto populate several fields at once

    I have a table that I am holding play data for a football game. Each play is a separate record. Each Record will have two video files associated with it, a sideline view and an endzone view. What I would like is for someone to click the button at the top of the form and for the button to give you three prompts:
    1) Game Number
    2) Name of first Endzone File
    3) Name of first Sideline File

    I would then want access to append to the end of the table and auto populate the following 4 fields
    1) Game Number (always the same)


    2) Play Number (start at 1 and Go up 1 each play)
    3) Endzoneview (a link to a file would start off VFD00023.wmv and go up 1 each play)
    3) Sidelineview (a link to a file would start off VFD01099.wmv and go up 1 each play)

    I would want it to do this until it ran out of files in the endzone and sideline video folders

    I was able to do this in excel, but after I create the button and tie a macro to it, I am lost.
    Any advise?
    thank you,
    Jerome

  2. #2
    Dal Jeanis is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2013
    Location
    Dallas TX
    Posts
    1,742
    Okay, so you're going to write VBA. Here's the pseudocode for the routine

    The person will enter game number, then enter (for example 23 and 1099)
    Your form will have a field with the game number, and two fields that contain the endzoneview and sidezoneview file numbers.
    Your VBA will read those fields and save them into variables.
    It will start the play number at 1.
    It will then enter a loop.
    It will build the names of the first two files by making each number 4 digits, and adding VFD on the front and .WMV on the end.
    It will check each folder for the file.
    If neither file is found, it will stop the loop.
    For each file that is found, it will build the path for the link.
    If one file is not found, that link will be built empty, blank, or something.
    The record will then be inserted into the table with game, play, and the two links.
    Then loop to the next play number.

    So, the question is, which part of this do you need examples for?

    Google "insert records sql VBA" and you should find lots of good examples.
    You'll also need the VBA to test for the existence of a file.

  3. #3
    learmanj is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    Jul 2013
    Posts
    8
    Apparently I know less that I thought I knew. I took a class in access and they taught us how to do popup using the find function...

    So need to know how to do that..
    This is what I have and know most of it is not right.... any advice

    Function Macro1()


    Prompt for Gameno
    Promt for ezfilename
    Promt for slfilname
    Play = 1
    While FileExists(tblgames.filepath.Gameno"\"ezfilename) Or FileExists(tblgames.filepath.Gameno"\"slfilename)
    INSERT INTO tblGameData ([Game Number], [Play Number], [EZ View], [SL View])
    VALUES (Gameno, Play, ezfilename, slfilename)
    Play = Pkay + 1
    ezfilename = "vfd" + (cat(ezfilename, 4, 4) + 1) + "wmv"
    slfilename = "vfd" + (cat(slfilename, 4, 4) + 1) + "wmv"
    EndWhile
    DoCmd.OpenForm "Gamedata", acNormal, "", "", , acNormal
    DoCmd.RunCommand acCmdDataEntry



    End Function

    Quote Originally Posted by Dal Jeanis View Post
    Okay, so you're going to write VBA. Here's the pseudocode for the routine

    The person will enter game number, then enter (for example 23 and 1099)
    Your form will have a field with the game number, and two fields that contain the endzoneview and sidezoneview file numbers.
    Your VBA will read those fields and save them into variables.
    It will start the play number at 1.
    It will then enter a loop.
    It will build the names of the first two files by making each number 4 digits, and adding VFD on the front and .WMV on the end.
    It will check each folder for the file.
    If neither file is found, it will stop the loop.
    For each file that is found, it will build the path for the link.
    If one file is not found, that link will be built empty, blank, or something.
    The record will then be inserted into the table with game, play, and the two links.
    Then loop to the next play number.

    So, the question is, which part of this do you need examples for?

    Google "insert records sql VBA" and you should find lots of good examples.
    You'll also need the VBA to test for the existence of a file.

  4. #4
    Dal Jeanis is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2013
    Location
    Dallas TX
    Posts
    1,742
    Okay, I don't do macros, so I can't comment on the syntax, but here are some notes.

    1) Before starting the loop, I would verify each file existed, and prompt for a fix at that point.

    2) After the loop starts, if the file doesn't exist, I would want to use Null rather than a nonexistent filename.
    Code:
    VALUES 
          (
          Gameno, 
          Play,
          IIF(FileExists(tblgames.filepath.Gameno"\"ezfilename),ezfilename, Null),
          IIF(FileExists(tblgames.filepath.Gameno"\"slfilename),slfilename, Null)
          )
    3) I would tend to put the 4-digit serial number of the file into a variable and increment, rather than extracting and incrementing them each time, but that's just a personal preference.

    Otherwise, your code/pseudocode should work when you get the syntax right.

  5. #5
    learmanj is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    Jul 2013
    Posts
    8
    I like both of those ideas. Thank you.. It is a matter of getting the syntax right. I am hoping someone on here can help out as it doesn't seem like it should be that complex.
    thanks again,
    Jerome

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

Similar Threads

  1. Auto Populate Fields & New Entry
    By Jarede in forum Forms
    Replies: 6
    Last Post: 02-12-2013, 05:23 PM
  2. Replies: 3
    Last Post: 02-02-2012, 09:48 AM
  3. Auto Populate two fields
    By funkygoorilla in forum Access
    Replies: 7
    Last Post: 08-31-2011, 09:06 PM
  4. auto populate mutiple fields
    By jomoan58 in forum Access
    Replies: 1
    Last Post: 07-23-2010, 01:03 PM
  5. Auto populate fields on a form
    By ldarley in forum Forms
    Replies: 0
    Last Post: 08-14-2008, 09:39 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