Page 2 of 3 FirstFirst 123 LastLast
Results 16 to 30 of 32
  1. #16
    accessnewtome is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Sep 2016
    Posts
    13
    Thank you thank you. Please take your time. As I said, I have very limited time but will work on every chance I get.

  2. #17
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    I'll have to be honest and say I don't use Macros but I do everything with VBA. Are you creating this for on-line or something? If not, macros are not necessary and frankly I find them limiting.

  3. #18
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Let's start with the ContractorsCustomers form. Are you aware that Access *always* save changes to a forms Record Source unless you take extraordinary steps?

  4. #19
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    I could probably work with macros if you want but I'll be learning at the same time so it will be a bit slower.

  5. #20
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    BTW, just get to it when you can. I have plenty to keep me busy and will just wait for you to have time to respond.

  6. #21
    accessnewtome is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Sep 2016
    Posts
    13
    Thanks for your understanding and again...thank you for your help!

    "I'll have to be honest and say I don't use Macros but I do everything with VBA. Are you creating this for on-line or something? If not, macros are not necessary and frankly I find them limiting."

    I would prefer to learn more VBA. I just did the macros because they seemed easy until things got more in-depth. I program AMX control systems and that programming is based off the C+ platform. So not completely new to programming...just don't know VBA.

    "
    Let's start with the ContractorsCustomers form. Are you aware that Access *always* save changes to a forms Record Source unless you take extraordinary steps?"

    Yes I am aware. I am used to programming touch panels where there is a button for everything. To keep with my trained brain patterns, I was trying to use buttons for everything. Plus I will be using this on a Microsoft Surface tablet so bigger target the better.

    "I could probably work with macros if you want but I'll be learning at the same time so it will be a bit slower."

    I would prefer to do VBA. I just have to learn it. But if you want to learn macros I'm in. But I agree they seem limiting and probably more work in the long run.

  7. #22
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    In the ContractorsCustomers you have a "Save and Exit" button. The Close you have selected *only* saves changes to the form when you select YES. As stated earlier, the changes to the data are *always* saved by Access when you close a form. You do know that you can convert all of your macros of each form to VBA with a selection from one of the menus, right?

  8. #23
    accessnewtome is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Sep 2016
    Posts
    13
    Yes, for the "Save and Exit" button, I had it set to "Prompt" but it would never prompt. So I had set it to "Yes".

    I did read somewhere in my journeys that you could convert the macros to VBA. Never tried it until now. I converted the "Save and Exit" button to VBA. When VB opens, I can see the programming behind it now...along with some programming that I tried from somewhere that didn't work and I deleted the button but not the code (button49 I believe). So I deleted that. So now I just have:

    '------------------------------------------------------------
    ' btnContractorCustomersSaveNewCustomer_Click
    '
    '------------------------------------------------------------
    Private Sub btnContractorCustomersSaveNewCustomer_Click()
    On Error GoTo btnContractorCustomersSaveNewCustomer_Click_Err


    DoCmd.Close acForm, "ContractorsCustomers"




    btnContractorCustomersSaveNewCustomer_Click_Exit:
    Exit Sub


    btnContractorCustomersSaveNewCustomer_Click_Err:
    MsgBox Error$
    Resume btnContractorCustomersSaveNewCustomer_Click_Exit


    End Sub

    This is where I'm assuming I need some sort of IF statement to see if there's a "ContractorID" associated with the open form...

    Unless we're going a totally different direction with design?

  9. #24
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    If I use the DoCmd.Close command, here's how I use it:

    DoCmd.Close acForm, Me.Name, acSaveNo

    I'll post again in a few minutes.

  10. #25
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    The top of *all* of your Class (code) modules should begin with:

    Option Compare Database
    Option Explicit

  11. #26
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    It also now looks like the "tblContractorsCustomers" should be a query with a Join rather than a table but I'm not positive yet.

  12. #27
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Just a couple of comments:

    With regards to the form close command. The syntax is:
    expression.Close(ObjectType, ObjectName, Save)

    Help says: "A AcCloseSave constant that specifies whether or not to save changes to the object. The default value is acSavePrompt."
    Notice the phrase "save changes to the object"; this means saving changes to the form object, not saving the data entered into the form.

    To close a form, I use: "DoCmd.Close acForm, Me.Name"

    ---------------------------------------------------

    I know nothing about your requirements, but looking at your dB, I think you need to change your relationships and the structure of a couple of tables. I would expect the structures/relationships to look like this:
    Click image for larger version. 

Name:	RTSI.jpg 
Views:	17 
Size:	39.9 KB 
ID:	26128
    Note: I did remove all spaces from object names and any special characters. I added the suffix "_PK" for primary key fields and "_FK" for foreign key fields.
    I didn't see any date fields, so I added one to the junction table "jnctContractorsCustomers".

    But then again, I could be wrong.....

  13. #28
    accessnewtome is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Sep 2016
    Posts
    13
    Thanks for the details...I will play around first chance and report back.

  14. #29
    accessnewtome is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Sep 2016
    Posts
    13
    OK, had a couple minutes.

    I tried re-doing my tables ssnafu to your suggestion...I get the same results.

    So stuck at:

    When I add a customer to my contractor; I click the button to add new customer.

    When the form opens, the contractors name and ID is filled in appropriately.

    When I close the form either by my save button or by the close window x, it saves the record to tblContractorsCustomers; but it does not have the ContractorID or Contractor Name associated with it.

    Also, when I go into my Contractors Table; the entry that saves into the tblContractorsCustomers does not show under the contractor.

    Danggummit!

  15. #30
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    You may wish to attach your db again so we can look at it.

Page 2 of 3 FirstFirst 123 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 13
    Last Post: 01-22-2015, 05:27 PM
  2. Replies: 6
    Last Post: 12-11-2013, 09:27 PM
  3. Replies: 4
    Last Post: 10-08-2012, 05:33 PM
  4. Replies: 2
    Last Post: 09-11-2012, 07:54 AM
  5. Replies: 1
    Last Post: 12-24-2011, 08:48 AM

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