Results 1 to 4 of 4
  1. #1
    ccordner is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Nov 2011
    Posts
    65

    Basic Form Design

    Hi



    I am quite new to using Access and I'm trying to design a form.

    I have, successfully, created a form with four combo-boxes and a calendar control. All of the combo-boxes need to lookup a value in a table and store the primary key in the appropriate field.

    I'm quite experienced in coding VBA for Excel, but have never done any in Access whatsoever!

    WHat I want to do is have three radio buttons. If you click one, it stores the date in the Calendar. If you click the other, it stores every day that week as seven different records. If you click the third one, it stores that date and the next 'n' days (from a textbox).

    How do I go about starting with this?

    Also, I shied away from using required fields in tables to start with, as it makes data entry quite sluggish. Can I set controls to 'required' on the form?

    Thanks
    Chris

  2. #2
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,530
    I don't think you can set a control to required (setting it at the table shouldn't have affected performance), but you can use the before update event of the form to test:

    http://www.baldyweb.com/BeforeUpdate.htm

    Does this help with the other?

    http://www.baldyweb.com/FirstVBA.htm

    Since you're experienced with VBA, I wasn't sure if you needed help with the code or just how to associate it with the buttons. From what you've described, the after update event of the buttons (or the frame if you use an option group) would be the place.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    ccordner is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Nov 2011
    Posts
    65
    Thanks for that.

    That is one big jump in the VBA code - seems to be very much like userforms in Excel.

    A few questions,

    1) Why is it len(me.somecontrol & vbNullString)? What does the nullstring do?

    2) Does Cancel=true abandon the update? Or is that a variable you'd have declared?

    3) I will need to test several fields. Assuming they pass them all on, it will just go ahead and write the record? So how do I go about asking it to write extra records? e.g. Date on calendar, plus following three days, as four separate records?

    The bit I'm a little shaky on now is knowing how to refer to records, add/amend/delete them.

    Thanks
    Chris

  4. #4
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,530
    1) That tests for both Null and a zero length string ("") which look the same to you and I but different to Access.

    2) Cancel = True abandons the update. If you start the code like the second link shows, Access will declare the variable for you:

    Private Sub Form_BeforeUpdate(Cancel As Integer)

    3) Is the form bound? Presuming so, it can create one record. You'd have to code for multiple records. One way would be to open a recordset on the target table, and use the AddNew method of that recordset to add records. Depending on your specifics, you could just do it x number of times, or use a For/Next loop to let the x be dynamic.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. A few basic form problems
    By cheese9799 in forum Forms
    Replies: 8
    Last Post: 02-15-2011, 02:43 PM
  2. Basic query design question
    By megabrown in forum Queries
    Replies: 1
    Last Post: 12-15-2010, 09:10 AM
  3. Basic design question
    By Brant in forum Access
    Replies: 2
    Last Post: 11-10-2010, 12:37 PM
  4. A basic question about database design
    By guitarbinge in forum Access
    Replies: 2
    Last Post: 11-05-2010, 03:29 PM
  5. Locking form with Visual Basic
    By rev_ollie in forum Forms
    Replies: 4
    Last Post: 04-29-2010, 07:27 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