Results 1 to 11 of 11
  1. #1
    New Lounger
    Join Date
    Aug 2001
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts

    ACCESS 2k (Access 2k)

    I am a little confused!
    Here's what I want to do:
    I have a main form and using command buttons, I want to open one of two different forms. When I open either of those forms I want to go to records that match one control from the originating form. The name of that control is "ACRONYM". If there aren't any records that match "ACRONYM" , I want the form that opened to automatically insert the "ACRONYM" into the new record.
    Here's what I did:
    I added an extra line of code
    right under the
    DoCmd.OpenForm statement that the command button put in
    It reads Forms!FormName!Control.SetFocus
    Forms!FormName!Control = Forms!OriginalFormName!Acronym

    it works for one of the command buttons, but when I repeated it for the other command button it continues to give me a message box that says "Object doesn't support this property or object."
    I don't know why it worked once and won't work twice.

    I'd appreciate any help that you can provide including a better way to write out the code.

  2. #2
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,623
    Thanks
    3
    Thanked 60 Times in 60 Posts

    Re: ACCESS 2k (Access 2k)

    I'm a little confused too, but it's been that kind of day. I assume you built your code using the button wizard, in which case you are probably applying a filter to the data source behind the second form. If not you will need to post the code for the button click so we can see what goes on prior to that. Your code appears that it should work, but I'm not sure how you get the second form into data entry mode if there aren't any records that match. some details on that would help too.
    Wendell

  3. #3
    New Lounger
    Join Date
    Aug 2001
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: ACCESS 2k (Access 2k)

    I FOUND it. I did use the wizard and then added code after that. (I'm learning to use helpful items along the way). I made a typo! One little letter wrong and the thing doesn't work! Didn't seem fair to me. I'm just learning and I'm being held to tight standards. Where's that learning curve grading system!
    But thanks for responding!

  4. #4
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,623
    Thanks
    3
    Thanked 60 Times in 60 Posts

    Re: ACCESS 2k (Access 2k)

    Gee, I hope it didn't take an entire month to sort that out! If you get really stuck on something, feel free to add to your post. The group here is more than willing to try to help, and all of us have been where you are. Do you have a good reference book to help you out? It is a long learning process - I've been at it for nearly 10 years with Access, and I still learn new tricks almost every day. Or maybe I learned them once before and then forgot - that's what happens to folks who work at this too long - you develop "Sometimers" - sometimes you remember the tips and tricks you need.
    Wendell

  5. #5
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: ACCESS 2k (Access 2k)

    Hear, Hear !!
    I have been in this game a while too, and you do forget from time to time.

  6. #6
    New Lounger
    Join Date
    Aug 2001
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: ACCESS 2k (Access 2k)

    It DID take me a month to find it! I'm impressed that I found the error and corrected it. I am miserable it took so long. Now I have a new problem <!post=(Post 130559),130559>(Post 130559)<!/post> and the reply <!post=(Post 130570),130570>(Post 130570)<!/post> isn't solving it. I suspect I'm missing a piece of the solution puzzle.
    Any ideas?

    Edited by Charlotte to add links to posts

  7. #7
    New Lounger
    Join Date
    Aug 2001
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: ACCESS 2k (Access 2k)

    The controls are bound and they store date and time respectively. The problem is that when I make this into a function in a standard module, and use an event to call it, I get nothing. It is as if it can't read the controls. I think this is a scope problem. I have never used a function in a form module and not sure how this is done.

  8. #8
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: ACCESS 2k (Access 2k)

    When you put a function in a standard module, it doesn't *know* about forms it might be called from. You can do several things to get around this:
    <UL><LI>Refer to a control on a form by explicitly naming the form it is on: Forms!frmMyForm!txtMyControl (where frmMyForm is the name of the form and txtMyControl is the name of a control on that form).
    <LI>You can refer to the form you function is called from as CodeContextObject, e.g. CodeContextObject!txtMyControl
    <LI>If you will be calling the function from just one form, you can move the function to the module behind that form. When you create event handlers for (controls on) the form, for instance OnClick routines for command buttons, you write them in the form module. You can also put subroutines and functions in this module. You open the form module by selecting View/Code.[/list]

  9. #9
    New Lounger
    Join Date
    Aug 2001
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: ACCESS 2k (Access 2k)

    In the module area, it's working perfectly when I go to the immediate window. I think I don't know how to call the function from the event handler. I am trying to put it on the "ON ENTER" event. So then I need to call the function, but I've tried CALL functionName, but that didn't work and then I tried it without the function name and that didn't work either. When I enter the text box nothing happens

  10. #10
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,623
    Thanks
    3
    Thanked 60 Times in 60 Posts

    Re: ACCESS 2k (Access 2k)

    If you want to call the function, you simply type the function name in the event property. I'm still a little confused however - you indicated that you are getting a date and time for some purpose. You can do that with simple event handler code as easily as calling a special function - I assume you are storing the function in the module associated with the form. We routinely do this for Access tables where we want to capture the date and time a record was edited, and the userid of the person who edited the record. For new records, we simply put a default in the table design. Is this the kind of problem you are trying to solve?
    Wendell

  11. #11
    New Lounger
    Join Date
    Aug 2001
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: ACCESS 2k (Access 2k)

    Thanks! I'm learning from books and it's the most basic information that they all leave out!
    Now I'll know how to call a function. I have it as an event handler now. When I had it working as a Function in a standard module, it stopped working when I moved it into the module behind the form. It seemed to be unable to read the values from the controls. As a function, I was supplying all the data in the function.
    I'm using a date and time along with other data to create a "primary key" for another table. I'm tracking seminar performances. That key identifies a specific performance. The code is using information that is gathered in order to put on the performance.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •