Results 1 to 11 of 11
  1. #1
    buckwheat is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Jan 2013
    Posts
    144

    cbo Issue and On Current Event

    Also posted at: http://www.mrexcel.com/forum/editpos...43&do=editpost

    Main form has a cbo box and several subforms. My cbo box returns a "0" and does not display the group # when selected if I have the following On Current Event on the main form:



    Private Sub Form_Current()
    cboGroup = Group_#
    End Sub

    I've always used this code is several database without trouble, does anyone have any idea what could be wrong. If I remove the code, the cbo displays the selection and subforms are populated correctly.

    The latest issue is that the form does not open clean . . . all subforms are populated. Can you advise please?

    Private Sub Form_Open(Cancel As Integer)
    'DoCmd.GoToRecord acDataForm, Me.Name, acNewRec
    End Sub

    Many Thanks

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    50,009
    Advise not to use spaces and special characters/punctuation (underscore is exception) in names. Better would be GroupNum or Group_Num.

    What is Group_# - a fieldname?

    Me.cboGroup = Me!Group_#


    Why is the line commented? It is not being executed.
    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
    buckwheat is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Jan 2013
    Posts
    144
    Unfortunately, the db I inherited . . . not sure what kind of trouble I will have if I rename the Group # field name. . . it is a primary key field.

    Regarding, "why is line commented" . . . I was advised through a thread to use this so the subforms would be displaying the record associated with the cbo selection.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    50,009
    So there is a also a space in Group # name, not actually an underscore - double whammy!

    Not really understanding why you have code to set combobox value. Is this an unbound combobox? If purpose of combobox is to input filter criteria, then it must be UNBOUND.

    Without that code line executed, the subforms will certainly be populated with records related to the record on main form. That code simply opens the form to a new record which would of course not have any related records. So I don't understand issue with 'form does not open clean'.
    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
    buckwheat is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Jan 2013
    Posts
    144
    Form should open clean (blank) . .. nothing in subforms until a selection is made from the cbo

  6. #6
    buckwheat is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Jan 2013
    Posts
    144
    I solved this by adding a blank row to the group table.

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    50,009
    Or could maybe set the subform DataEntry property to Yes if you don't want to show existing records.
    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.

  8. #8
    buckwheat is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Jan 2013
    Posts
    144
    In your earlier comment regarding code:

    Private Sub Form_Open(Cancel As Integer)
    'DoCmd.GoToRecord acDataForm, Me.Name, acNewRec
    End Sub

    I realize you asked why include when it doesn't execute . . . I'm guessing because of the ' meaning just a comment, that does not appears in the actual code . . slip of the finger.

    For the subform. . . I want users to be able pick a group from the drop down, when I change the main form to "Yes" data entry," even though the subforms are set to "No" data entry, the forms will not populate to display the cbo selection. So I'll leave as it . . . behind schedule. Thanks.

  9. #9
    buckwheat is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Jan 2013
    Posts
    144
    The cbo for my form is setup to select a group # and have all subforms populate with relative data for selected item. I believe I can advance to the last record to get a blank form to add new data, but what can I do to have the cbo accept entries should a new group need to be added? I have set "yes" to add, delete, edit, etc., but it doesn't seem to accept any new entry in the cbo box.

  10. #10
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    50,009
    Investigate the NotInList event of combobox. Here is one http://www.blueclaw-db.com/access_no...ed_example.htm
    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.

  11. #11
    buckwheat is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Jan 2013
    Posts
    144
    Ok many thanks. Another work around I just realized is to put a second "group #" field as text. Add a new record button or use the record selector. Users can select from list or type the new group in the group text field. Thanks again for the link.

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

Similar Threads

  1. Access 2010 Query or Event Procedure Issue?
    By justphilip2003 in forum Queries
    Replies: 22
    Last Post: 04-19-2013, 02:39 PM
  2. How to suppress Current event code?
    By RonL in forum Forms
    Replies: 5
    Last Post: 04-12-2013, 12:43 PM
  3. Information message on current event
    By justauser in forum Forms
    Replies: 5
    Last Post: 02-07-2012, 12:15 PM
  4. NotInList event issue
    By elinde in forum Forms
    Replies: 1
    Last Post: 04-01-2011, 08:43 PM
  5. Current Record Update Issue
    By SALPBE in forum Programming
    Replies: 0
    Last Post: 02-23-2011, 03:02 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 - Senior Forums