Page 1 of 2 12 LastLast
Results 1 to 15 of 18
  1. #1
    mackmaru is offline Novice
    Windows 10 Access 2007
    Join Date
    Jan 2019
    Posts
    12

    Corrupted database?

    Access 2007
    I have a issue creating combo boxes to find a current record
    I use the wizard to create the combo box
    - Select records on my form based on the value I selected in my combo box
    - Select the Field I want to have in my search
    - complete the wizard as required

    Then when using the combo box, I make my selection and it just doesn't work. The record does not update to what I've selected. The Event Procedure for AfterUpdate is

    Object Type - blank
    Object Name - blank
    Record - First
    Where Condition - ="[Membership ID] = " & Str(Nz(Screen.ActiveControl,0))

    When I try to see the VB Code, Access always shuts down and restarts.



    Guidance required here please.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    I don't use the wizards because they do things I don't like.

    What VB code? Looks like you are using macro - I only use VBA.

    Exactly how are you 'trying to see the VB Code'?

    Is [Membership ID] a number data type?

    Advise not to use space nor punctuation/special characters (underscore only exception) in naming convention.

    If you want to provide db for analysis, follow instructions at bottom of my post.
    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
    mackmaru is offline Novice
    Windows 10 Access 2007
    Join Date
    Jan 2019
    Posts
    12
    I've added the underscore on the master copy. Here is the zip copy for you. Please check and let me know.
    Attached Files Attached Files

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Code behind Form_180s:

    Code:
    Membership ID = [Forms]![Form_Membership]![Membership ID]
    Note the space in Membership ID. This code will fail. How should VBA understand that Membership and ID are parts of 1 name? That's what [ ] delimiters are for. Or don't use spaces in names. Also, if you open Form_180s to an existing record, this code would replace value in existing record. This code should only run if the form opens to a new record. You changed name of field but not the textbox.

    Code:
    If Me.NewRecord Then Me.Membership_ID = [Forms]![Form_Membership]![Membership_ID]
    Have you considered using a form/subform arrangement?

    Why do you have Charges field in Table_Membership?

    Aside from spaces, you are also using punctuation/special characters in naming convention. Advise not to do that, with the exception of underscore. Report still references the old field name in textbox.
    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
    mackmaru is offline Novice
    Windows 10 Access 2007
    Join Date
    Jan 2019
    Posts
    12
    Membership ID = [Forms]![Form_Membership]![Membership ID]
    I found this issue and fixed it.

    Where do I put this? If Me.NewRecord Then Me.Membership_ID = [Forms]![Form_Membership]![Membership_ID]
    My combo box still not working.

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    That If Then code is to replace the original line. However, need to use Current event instead of Open.

    If you mean the combobox on Client Form - it works for me.
    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.

  7. #7
    mackmaru is offline Novice
    Windows 10 Access 2007
    Join Date
    Jan 2019
    Posts
    12
    i dont think I'm fully understanding this. I cant get it to work.
    I managed to get to VB for the ComboBox AfterUpdate
    added this line line: If Me.NewRecord Then Me.Membership_ID = [Forms]![Form_Membership]![Membership_ID], Is this right.
    Sorry for the hassle mate.

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    The combobox embedded macro was working for me. Did you convert it to VBA?


    Instead of
    Code:
    Private Sub Form_Open(Cancel As Integer)
        Membership ID = [Forms]![Form_Membership]![Membership ID]
    End Sub
    Use
    Code:
    Private Sub Form_Current()
        If Me.NewRecord Then Me.Membership_ID = [Forms]![Form_Membership]![Membership_ID]
    End Sub
    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.

  9. #9
    mackmaru is offline Novice
    Windows 10 Access 2007
    Join Date
    Jan 2019
    Posts
    12
    This is what I mean when I say I can't use VBA. Access keeps shutting down. Is it possible for you to send me your copy of my db and I'll see if that works?

  10. #10
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    But I had no problem opening your db and the VBA editor so it can't be db corruption. You cannot open the VBA editor? This an issue with another db?

    If you can't use VBA, then what do you mean by "I managed to get to VB for the ComboBox AfterUpdate"?
    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
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,933
    This is what I mean when I say I can't use VBA. Access keeps shutting down
    there are a number of ways of opening the vba editor - which one are you using?

  12. #12
    mackmaru is offline Novice
    Windows 10 Access 2007
    Join Date
    Jan 2019
    Posts
    12
    VBA is working ( It must have been me) I'm opening up from Database Tools toolbar.
    Do I put this code in now?
    Private Sub Form_Current()
    If Me.NewRecord Then Me.Membership_ID = [Forms]![Form_Membership]![Membership_ID]
    End Sub

  13. #13
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    That code must be behind form. Another way to open VBA editor is through the form event property on Property Sheet. Select [Event Procedure] then click the ellipsis (…) to open editor at that event code, add the line shown. You must have done this at some time because the form already Load event code.

    Or if you have the form's code module open in the editor, copy/paste the suggested code, all 3 lines.
    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.

  14. #14
    mackmaru is offline Novice
    Windows 10 Access 2007
    Join Date
    Jan 2019
    Posts
    12
    That's where it crashes
    " Property Sheet. Select [Event Procedure] then click the ellipsis (…) to open editor at that event code"
    I'll try this "

    Or if you have the form's code module open in the editor, copy/paste the suggested code, all 3 lines."

  15. #15
    mackmaru is offline Novice
    Windows 10 Access 2007
    Join Date
    Jan 2019
    Posts
    12
    is it possible for you to send me your copy and see if that works?

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Database Corrupted?
    By knowshowrosegrows in forum Access
    Replies: 2
    Last Post: 09-23-2015, 09:16 AM
  2. MS Access .mdb & .ldb database corrupted
    By ewaldstrub in forum Database Design
    Replies: 2
    Last Post: 06-09-2015, 01:51 PM
  3. Database Corrupted
    By waqas in forum Forms
    Replies: 3
    Last Post: 09-14-2011, 01:35 PM
  4. Database corrupted?
    By kctxucop08 in forum Access
    Replies: 3
    Last Post: 07-21-2011, 08:54 AM
  5. Corrupted Database
    By evander in forum Access
    Replies: 1
    Last Post: 04-29-2010, 12:58 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