Results 1 to 2 of 2
  1. #1
    Nailati is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Feb 2012
    Posts
    15

    Combo Box Code Not Meshing with New Record Button -- can't update combo box value

    Hi all,
    I'm working on a form that will allow me to browse publications, sorted by a number called a TMIN. The combo box "ComboTMIN" navigates through records, and displays the current TMIN. However, it doesn't work so well when I try to add a record with a separate button, and then enter a value into the combo.

    Info about this combo box --
    Name: ComboTMIN
    Row Source: SELECT [tbl_Publications].[TMIN] FROM tbl_Publications;
    Row Source Type: Table/Query
    Event - After Update: Embedded Macro: searches for first record where ="[TMIN] = " & "'" & [Screen].[ActiveControl] & "'"

    Code used to display current record TMIN in combo box --
    (Form - Event - On Current)
    Private Sub Form_Current()
    'Display current TMIN in combo box
    Me.ComboTMIN = Me.TMIN
    End Sub

    New Record button -- just a basic button with an Embedded Macro -- GoToRecord - New.

    The combo box works fine for navigation, and the New Record button successfully adds a record, but doesn't allow me to enter a TMIN for the new record. Once I type anything into the TMIN combo, of course, the After Update action searches for a matching record, doesn't find one, and I'm dumped back into the new record. (I can update all the other fields in the record.) I'm sure there's a way around this contradiction but I'm a bit stuck--any ideas? Thanks!

  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
    You could have the unbound combobox exclusively for navigation and a bound textbox for entering the new TMIN value.

    Is there some other field that must always have value? Could use this field as a condition for the AfterUpdate code. If that field is null then must be on a NEW record, if not null then must be on existing record.
    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: 12
    Last Post: 03-14-2012, 10:54 AM
  2. filtering of combo box / vba code
    By Kotoca in forum Programming
    Replies: 2
    Last Post: 02-08-2012, 08:15 AM
  3. Replies: 7
    Last Post: 11-23-2011, 08:14 PM
  4. Replies: 16
    Last Post: 06-21-2011, 09:08 AM
  5. Update Record button
    By Steven.Allman in forum Forms
    Replies: 1
    Last Post: 02-16-2011, 02:15 PM

Tags for this Thread

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