Results 1 to 7 of 7
  1. #1
    smartflashes is offline Novice
    Windows XP Access 2003
    Join Date
    Jan 2012
    Posts
    12

    Assigning numbers to certain fields


    Dear friends,
    I need help with the attached form. I need to automatically distribute numbers to certain group of fields according to the selection of the user. i.e. on opening the form, the user is asked to enter the first number of the group and then the last number of the group. Numbers of the group will appear and a textbox to write a beginning number to start with to assign a group of numbers to that group. A button to start the procession and another button to re-open the for to continue assigning other groups.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Need to use an UPDATE query. I use only VBA, no macros.

    1. Don't use input parameter prompts in query. Use textboxes on the form for user input.

    2. The criteria in the query will refer to the textboxes for input. The form should open without prompting for inputs.
    [Forms]![secret]![Start] And [Forms]![secret]![End]));

    3. VBA code in the Distribute button click:
    CurrentDb.Execute "UPDATE Table1 SET secret=" & Me.c1 & " WHERE seat BETWEEN " & Me.Start & " AND " & Me.End
    Me.Requery
    Last edited by June7; 01-19-2012 at 01:47 PM.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    smartflashes is offline Novice
    Windows XP Access 2003
    Join Date
    Jan 2012
    Posts
    12
    Thanks, June, but this is what I don't exactly want.
    Attached is a picture that may illustrate what I want.

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Why should the form open with prompts? If they want to change the inputs will have to close form and reopen to get the prompts again. Or maybe execute the Me.Requery line after the UPDATE sql will trigger the prompts again.

    Why not open form with blank fields and users input there?

    Whichever way, the UPDATE is still needed.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    smartflashes is offline Novice
    Windows XP Access 2003
    Join Date
    Jan 2012
    Posts
    12
    Quote Originally Posted by June7 View Post
    Why should the form open with prompts? If they want to change the inputs will have to close form and reopen to get the prompts again. Or maybe execute the Me.Requery line after the UPDATE sql will trigger the prompts again.

    Why not open form with blank fields and users input there?

    Whichever way, the UPDATE is still needed.
    It's Ok. I changed the design as you suggested. No need to open the form with prompt. I just want to distribute a series of numbers to certain fields as illustrated in the picture. The user will input numbers for Start and End and will input a number to begin distributing with. On clicking the button, the process starts as appears in the picture. What you didn't get was that I wanted a series of numbers, and not the same number, to be assigned to the group. I wish you get what I want to do. Thanks.

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Oh, see that now, had to blow up the image for my eyes - LOL! Then something like:

    Dim i As Integer
    If Not IsNull(Me.End) And Not IsNull(Me.Start) And Me.End > Me. Start Then
    For i = 1 to Me.End - Me.Start
    CurrentDb.Execute "UPDATE Table1 SET secret=" & Me.c1 + i -1 & " WHERE seat = " & Me.Start + i - 1
    Next
    Me.Requery
    End If
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    smartflashes is offline Novice
    Windows XP Access 2003
    Join Date
    Jan 2012
    Posts
    12
    Thanks, June.
    Everything works well now.

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

Similar Threads

  1. Import Errors - Fields with Numbers and Letters
    By Eekers in forum Import/Export Data
    Replies: 5
    Last Post: 01-10-2012, 02:52 PM
  2. Replies: 1
    Last Post: 11-29-2011, 08:43 AM
  3. assigning a variable
    By crowegreg in forum Programming
    Replies: 1
    Last Post: 08-22-2011, 05:55 PM
  4. Assigning value to an image
    By cdzajp in forum Forms
    Replies: 1
    Last Post: 06-16-2011, 12:05 PM
  5. assigning probability
    By TheShabz in forum Programming
    Replies: 1
    Last Post: 05-06-2010, 12:50 PM

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