Page 1 of 2 12 LastLast
Results 1 to 15 of 20
  1. #1
    2 Star Lounger
    Join Date
    Oct 2004
    Location
    Evansville, Indiana, USA
    Posts
    111
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Write to table on form open. (2000)

    Is there a way to automatically write certain records in a table when a form is open using VB?

  2. #2
    3 Star Lounger
    Join Date
    Apr 2001
    Location
    Joliette, Quebec, Canada
    Posts
    290
    Thanks
    9
    Thanked 0 Times in 0 Posts

    Re: Write to table on form open. (2000)

    This may be bad advice, but create a macro to run a query to write to the table, then on the on open property of your form; run the that macro. Then convert you macros to vb.

  3. #3
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: Write to table on form open. (2000)

    Would you expand on what you want to do.

  4. #4
    2 Star Lounger
    Join Date
    Oct 2004
    Location
    Evansville, Indiana, USA
    Posts
    111
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Write to table on form open. (2000)

    I have a subform that is set to continuous. When the form is brought up for the very first time, the subform is empty. When the user inputs data, it is stored to my table. Then the next time the form is opened, a query is run and certain records are displayed. What I want to do is have 7 records already in the subform when it opens the first time. I can't put them in the subform design becasue everytime I want a new record, it adds those 7 records. I only need these seven to be created the first time.

  5. #5
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Write to table on form open. (2000)

    That doesn't really explain enough. Do you want seven *empty* records created? That suggests a very poor table design. If you are populating some value in each record, that can be done in code, but it still leaves questions unanswered.
    Charlotte

  6. #6
    2 Star Lounger
    Join Date
    Oct 2004
    Location
    Evansville, Indiana, USA
    Posts
    111
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Write to table on form open. (2000)

    On the subform, the user gives the input - job#, ActivityCode, then inputs time in one of 7 textboxes (one for each day of the week) Some boxes will be null or every box can contain info. When this form is opend for the first time, I have 7 job numbers that I want to automatically show up. These are default that every user will use. The others will vary depending on which project they work on each week. So is there a way to create these seven records when the form is opened for the first time, or is there a better way of doing this?

  7. #7
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: Write to table on form open. (2000)

    Why don't you do it manually, if it is only to be done the very first time the main form is opened.

    If you want to populate the subform records everytime the main form is opened then put the code in the OnOpen event of the main form.

    I still don't get what you are trying to do or why.

  8. #8
    2 Star Lounger
    Join Date
    Oct 2004
    Location
    Evansville, Indiana, USA
    Posts
    111
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Write to table on form open. (2000)

    I really don't understand why it has to be done this way either. The request asked for it to be this way and I am trying to figure it out.

  9. #9
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Write to table on form open. (2000)

    You have to question requests that you don't understand, especially if they come from users, who haven't a clue as to HOW any of this should be done. Find out what the requester is trying to accomplish. Then come back with your questions about how to do it and *whether* to do it that particular way.
    Charlotte

  10. #10
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Write to table on form open. (2000)

    That's what they want to accomplish, not why they want to do it that way. It's easy to get the distinction confused because they sound like the same thing, but they really aren't. Keep in mind that they are often simpler ways to do things. For instance, you could provide 7 buttons with the name of a day on each button and pop up an input box to accept the information for that day when they clicked on it. Then your form could create a record for that day.
    Charlotte

  11. #11
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: Write to table on form open. (2000)

    Is the problem that when you write a new record to the table behind the main form, then it needs to write the 7 records to the table behind the subform?

    If so then put the code in the AfterInsert on the main form.

  12. #12
    2 Star Lounger
    Join Date
    Oct 2004
    Location
    Evansville, Indiana, USA
    Posts
    111
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Write to table on form open. (2000)

    Can you please give a sample of what the code should be?

  13. #13
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: Write to table on form open. (2000)

    Does this response mean you agree that when a record is written in the main form then the 7 records need to be written in the subform?

    You will have to give me more details. Better than that why don't you send a compacted/zipped version of your database giving us the details of what form you are doing this in.

  14. #14
    2 Star Lounger
    Join Date
    Oct 2004
    Location
    Evansville, Indiana, USA
    Posts
    111
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Write to table on form open. (2000)

    Post deleted by threeieng11774

  15. #15
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Write to table on form open. (2000)

    Additional information is in <post#=426105>post 426105</post#>, which is now locked to keep the topic together.
    Charlotte

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •