Results 1 to 11 of 11
  1. #1
    Join Date
    Oct 2012
    Posts
    8

    Unanswered: Auto-populate code does not work

    Hi,
    new to Access and I wonder what makes this code not working:

    Private Sub Paikka_AfterUpdate()
    If Not IsNull(Me.Paikka.Value) Then
    Paikka.DefaultValue = """" & Me.Paikka.Value & """"
    End If
    End Sub

    Should work as autofill of the text field Paikka based on previous saved record.

    Is there something wrong with the
    - the code
    - the definition of the textfield or what?
    Is there maybe some setting for the text field itself that I have over looked?

    Thanks.....

  2. #2
    Join Date
    Apr 2004
    Location
    Derbyshire, UK
    Posts
    789
    Provided Answers: 1
    Hi

    You have not indicated why it isn't working i.e. what hppens?

    If the Control is not bound to a field, then I don't thing it will work anyway.


    MTB

  3. #3
    Join Date
    Oct 2012
    Posts
    8
    Yes,
    the code is bound to a box and field, both with the same name, Paikka.
    And absoluetly nothing happens.

    I can fill the field by hitting control and ', but not with the code!

  4. #4
    Join Date
    Apr 2004
    Location
    Derbyshire, UK
    Posts
    789
    Provided Answers: 1
    I have pasted you code into a form with textbox control of the same name, bound to a field of the same name and it seem to work fine.

    So I don't know what to suggest.

    Note this dynamic default will not be saved when the form is closed!

    MTB

  5. #5
    Join Date
    Oct 2012
    Posts
    8
    Exactly!
    I have tried and tried, but still it does not work.
    I know about the form closing, so that it is not the problem. There must be something fundamentally wrong with my table or.... I am normally using Swedish keyboard, I even tried to write everything with UK keyboard, yes I know it should not matter, but I tried anyway.
    I have the same problem with a date field, I have tried with every kind of field I can think about.

    Edit:
    I added a new textfield to my table.
    I saved and closed the table.
    I opened my form (bound to the same table) in design view.
    I added the new field to the form.
    I opened the eventeditor.
    I pasted the same lines (but with the new field name).
    I closed the editor.
    I opened the form in table view
    I tested the Event.
    Still nothing happens.

    My table is default everything.
    My form is default everything.

    What is going on ???
    Last edited by Petrus27; 10-17-12 at 11:16.

  6. #6
    Join Date
    Oct 2012
    Posts
    8
    There must be something wrong with my tables!
    I started a new small table, then a form, then pasted the code:
    It works OK.
    Then I designed another table, included date field.
    Then I added a combo box to my form, pasted the code.
    It works OK.

    Then I added my basic data (400 bird names) by copy paste from Excel into my above mentioned table to be used in the combo box. So far it all looks good. Also added some more text fields into my original table.
    Pasted the code.
    IT WORKS NO MORE!

  7. #7
    Join Date
    Oct 2012
    Posts
    8
    In case someone would be following this thread - please help!
    I created a new database, checked after each step that the originally put question concerning auto-fill is working. It worked OK.
    It worked for about 1 day.
    Then it stopped working without anything being changed concerning the basic structure or codes. However, many names and data fields have non-anglo letters, like "umlaut", i.e. , , ets.
    Can this really be the reason????? I can think of nothing else.
    Petrus27

  8. #8
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    Quote Originally Posted by Petrus27 View Post

    ...Can this really be the reason?????
    Given that the code posted is perfectly valid, and given the steps you've taken, it must have something to do with that or with the Swedish keyboard, or the combination of the two!

    I have no way to check that out, of course, but with a system running in the US, even when using umlauts, it works correctly.

    Linq ;0)>
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  9. #9
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    if you copy and pasted the code, then it may be worth checking that the form designer 'knows' about event
    check the properties for the relevant control and see if the right event is set to execute code
    I'd rather be riding on the Tiger 800 or the Norton

  10. #10
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    While your point about pasted in code sometimes not being recognized, which is to say the event doesn't appear as an

    [Event Procedure]

    in the Property Pane, the fact that

    Quote Originally Posted by Petrus27 View Post

    ...It worked for about 1 day...
    would suggest that this isn't the problem in this case, would it not?

    I'm somewhat leery of the statement

    Quote Originally Posted by Petrus27 View Post

    ...it stopped working without anything being changed concerning the basic structure or codes...
    What some developers, especially neophytes, consider to be 'inconsequential changes,' and what the Access Gnomes consider to be 'consequential changes,' are sometimes miles apart!

    What, exactly, did change, other than data being entered?

    Linq ;0)>
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  11. #11
    Join Date
    Oct 2012
    Posts
    8
    What some developers, especially neophytes, consider to be 'inconsequential changes,' and what the Access Gnomes consider to be 'consequential changes,' are sometimes miles apart!

    What, exactly, did change, other than data being entered?

    Linq ;0)>
    Thank you for taking the time! Of course you are rightin your statement above. Some things were changed.
    I know it is not the best way to build a table by using a BirdName as a key, but in my case i tought it would be a simple way. The names in Finnish have many umlauts. Some of them even start with an umlaut.
    Now to "minor" changes.
    1. I entered for the first time in this particular table's history a bird starting with an umlaut. Could not make sure if this is the cause, maybe not.
    2. I changed the form to design view. Created two new text fields. Did not specify any data column, query or else related to these two new fields. Did nothing else, except saved the form view, opened the form again and tried to enter data same way as before. Now auto-fill had stopped working.

    As described earlier, I tried to build my db carefully checking the function after each change or modification. It is a complete mystery to me.

    I deleted the to new fields. But it did not help.

    So I saved the whole db, saved it again now with a different name. Closed access, Opened access again, now with db saved under the new name, deleted the two new fields, but it did not help. Maybe this is not a good way to check things, but I could think of little else.

Posting Permissions

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