Results 1 to 11 of 11
  1. #1
    AndyRob1973 is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2020
    Posts
    81

    Command button error

    Hello,



    I have also posted this in Command button error | Access World Forums (access-programmers.co.uk)

    (I've attached the database that I'm talking about below)

    I have added a command button to the form ‘frm_PatientPlan’ called ‘Disable/Enable Invoice Code’, which works on a field called ‘Invoice Code’ that is on its subform ‘frm_PatientSchAll_subform’. It seems to work ok when I open up ‘frm_PatientPlan’ and click the button.



    However, in practice the user will start with the form ‘frm_PatientList’, click on the Patient’s ID which opens up the ‘frm_PatientPlan’ for that patient. But when the ‘Disable/Enable Invoice Code’ is clicked I get the error.






    Could anyone help please?

    Thankyou.Option2_10 - Master.zip







  2. #2
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,929
    What is the line of code creating the error? Click debug and it will be highlighted

  3. #3
    AndyRob1973 is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2020
    Posts
    81
    Hi there,

    It is :

    If Forms(frm_PatientPlan).frm_PatientSchAll_subform.F orm.InvoiceCode.Enabled Then



    Thank you!

  4. #4
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,555
    Just a quick Google shows the bang should be used, not the dot?
    https://docs.microsoft.com/en-us/office/vba/api/access.form

    ! instead of .

    Seems to be confirmed on another search. https://www.access-programmers.co.uk...b-form.318493/
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  5. #5
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,879
    You need quotes around the form name.
    Code:
    Forms("frm_PatientPlan").whatever
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

  6. #6
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,879
    This works
    Code:
        If Me.frm_PatientSchAll_subform.Form.invoicecode.Enabled = True Then
            Me.frm_PatientSchAll_subform.Form.invoicecode.Enabled = False
        Else
            Me.frm_PatientSchAll_subform.Form.invoicecode.Enabled = True
        End If
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

  7. #7
    Micron is online now Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,422
    Why have the Else? Basically if it's true, make it false. No need to make it true when it already is. Or am I missing something?
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  8. #8
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,157
    Most of these answers and others on the other forum https://www.access-programmers.co.uk...-error.319128/
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  9. #9
    Micron is online now Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,422
    I misinterpreted the intent, so yeah, I missed the mark. That often happens when I post before coffee.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  10. #10
    AndyRob1973 is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2020
    Posts
    81
    Thankyou Minty - just checking that it's ok to do this as I put a link on the first post.

    Quote Originally Posted by Minty View Post
    Most of these answers and others on the other forum https://www.access-programmers.co.uk...-error.319128/

  11. #11
    AndyRob1973 is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2020
    Posts
    81
    Thankyou all,

    I have learnt a lot from all your replies.

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

Similar Threads

  1. Command Button Error handling
    By Hank153 in forum Reports
    Replies: 2
    Last Post: 10-28-2013, 11:08 AM
  2. Network error and Command Button error
    By Sandra Williams in forum Access
    Replies: 1
    Last Post: 05-26-2013, 09:25 AM
  3. Error on command button wizard
    By jcor in forum Forms
    Replies: 7
    Last Post: 05-10-2013, 09:34 AM
  4. Replies: 2
    Last Post: 07-24-2012, 12:44 PM
  5. Error Import Command Button
    By kowen091010 in forum Access
    Replies: 4
    Last Post: 12-15-2011, 07:56 AM

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