Results 1 to 4 of 4
  1. #1
    vad77 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Dec 2013
    Location
    USA
    Posts
    101

    Combo box to show for new record only

    I am currently working on a database to keep track of accounts, invoices for accounts, techs assigned and contacts. So far I have my SiteInfo table, SiteContacts and SiteEquip. My primary key field for the site is SiteID. The other tables have there own ID field and the SiteID to tie them together. MY relationships are set up as one-to-many from the SiteInfo to the other two tables SiteID field. My contacts primary key is called ContactID and equipment table is EID.
    I created a form to add/view the contacts off of a query called qContactList. The query contains the SiteInfo table and Contact table. I want to add one button called New Contact and I want to use a combo box to select the site ID and enter it in the SiteID field in the contact table. I want to have the combo box hidden when in edit mode, just looking at the list, and create a button that will go to a new record and make the combo box visible for new records only. Then would like to have create a save/new button for the purpose of adding more. Then just a save button that will make the combo box hidden and go back to edit mode to see all records.


    I know this is a lot to ask but my vba skills though getting better thanks to all you guys but they are still limited.
    Thanks in advance for your responses.

    Thanks!
    V

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,545
    Perhaps you could start with the visible property of the combo box set to No. Then have a couple of lines of code in the forms On Current event to see if the current record is a new record and then set the visible property accordingly. Something like:
    Code:
    If Me.NewRecord Then
      Me.NameOfCombo.Visible = True
    Else
      Me.NameOfCombo.Visible = False
    End If
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    vad77 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Dec 2013
    Location
    USA
    Posts
    101
    Thanks Bob! That works great I think I had the code almost figured but wasn't sure on whose event to put the code. I think now I can figure out the other things I want to do.

    V

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,972
    Simpler code, one-liner:

    Me.NameOfCombo.Visible = Me.NewRecord
    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.

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

Similar Threads

  1. Replies: 11
    Last Post: 07-29-2013, 07:49 AM
  2. Replies: 1
    Last Post: 01-23-2013, 10:44 AM
  3. Combo Box value hide/show Image
    By alyon in forum Access
    Replies: 7
    Last Post: 12-13-2012, 09:48 AM
  4. Combo box Value Must Show an object: How To
    By vdanelia in forum Forms
    Replies: 6
    Last Post: 02-03-2011, 04:16 AM
  5. Replies: 4
    Last Post: 10-18-2010, 09:44 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