Results 1 to 13 of 13
  1. #1
    Synergy.ron@gmail.com is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Oct 2020
    Location
    washington
    Posts
    126

    Question undefined user type.

    Attachment 45463Attachment 45464Attachment 45465I created 2 functions. The second is called by the first. Yet I get an error on compiling mssage.Attachment 45463 Attachment 45464



    What (in english ) does this mean? What did I do to cause this? thanks....
    Last edited by Synergy.ron@gmail.com; 06-10-2021 at 05:49 PM. Reason: attach database file

  2. #2
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    A few possibilities but what stands out the most for me is that 'snum i" probably looks like an undefined property or function to Access.
    Perhaps you mean snum & i or more likely, Mid(snum, i, 1)

    Also, you don't have to declare snum in the procedure when you're passing the variable to the function anyway. Odd that you don't declare i though.
    EDIT - another oddity is that you intend to loop, then make the function return only the result of the expression in the very last iteration of the loop. So if it loops 20 times, the function will only return the 20th value, so I don't see the point of that.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    ssanfu is offline Master of Nothing
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    The "User-defined type not defined" error is because
    Code:
    Public Function getauthcode(snum As Variant) As Text
    Should not be Text - should be STRING


    You have global variables defined (Module level) as well as the procedure level. ??

    I also think the line should be
    Code:
            s4 = s4 & Chr(Mid(snum, i, 1) + 65)
    Notice the comma after snum

  4. #4
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    Good catch but the highlight is on the s4 line - or is that just highlight added by the OP? That would be a bad idea to to that for a post.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  5. #5
    ssanfu is offline Master of Nothing
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    @Micron,
    When I tried to compile the code, the compiler highlighted the line
    Code:
    Public Function getauthcode(snum As Variant) As Text
    The s4 line was highlighted because of the syntax error in the MID function. (missing comma)

    As usual, I took so long finding the errors, you replied before I could......

    I'm almost keeping up with you ....

  6. #6
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    I agree, compiling (and now that I've tried calling such a function without compiling) it errs on the first line regardless. So if the yellow highlight is added by the OP, that's not a good thing as it will throw people off track. If it's not, then I don't see how it could run at all.
    Methinks it is I who has to catch up to you
    Click image for larger version. 

Name:	1ssanfuCount.jpg 
Views:	39 
Size:	10.7 KB 
ID:	45467
    9329 vs 8942
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  7. #7
    ssanfu is offline Master of Nothing
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    But comparing posts/year.:
    YEAR POSTS POSTS/YEAR
    Micron 2014 8946 1278
    ssanfu 2010 9329 848

    I'm not doing that well.....





  8. #8
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    Quantity never beat quality...
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  9. #9
    Synergy.ron@gmail.com is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Oct 2020
    Location
    washington
    Posts
    126
    thanks for the guidance. i've noticed that vb sometimes (without warning) corrects my typing. I suspect that I simply continue to 'see' the old typing despite the change....Anyway it is quite a learning curve getting to know the vb editor; here is the latest brain teaser......The thing of it is "there clearly is an rs.edit. Or does the err mean something not stated? thanksAttachment 45507Attachment 45508

  10. #10
    ssanfu is offline Master of Nothing
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    You don't show how the record set was declared or how it was opened, nor do you show (the code) how/where you close the record set.

    In the code, You you have
    Code:
    rs.Edit
    rs.MoveFirst
    rs.Fields![serialnumber] = s3
    The MoveFirst commandm is the problem. Apparently, moving to a different record does an automatic save.

    I don't know why you would want to edit the record, then move to the first record, but try this:
    Code:
    .
    .  some commands
    .
       rs.MoveFirst
       rs.Edit
       rs.Fields![serialnumber] = s3
       rs.Update
    
       rs.Close
    .
    .more commands
    .
    .
    Al least I didn't get an error.......

  11. #11
    Synergy.ron@gmail.com is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Oct 2020
    Location
    washington
    Posts
    126
    yes, that did it. Can you recommend a good learning source that deals with the idiosyncratic messages that access produces.? Thank you for the assistance.

  12. #12
    ssanfu is offline Master of Nothing
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    I don't know of any source...... Sometimes the error messages are kinda obtuse and you have to start testing code...

  13. #13
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    Can you recommend a good learning source that deals with the idiosyncratic messages that access produces.?
    Yes. It's called Google and likely goes by other names as well. Since some Access errors have multiple causes, while others have only one, why not use a search engine to return the related posts from all sources related to an error number and message rather than just asking at one particular node in the internet universe?
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

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

Similar Threads

  1. Prompt User To Type Email Addresses
    By Eranka in forum Access
    Replies: 3
    Last Post: 06-02-2018, 11:52 AM
  2. Undefined user-defined data type
    By gar in forum Programming
    Replies: 4
    Last Post: 12-07-2017, 08:26 AM
  3. User-Defined Type Error?
    By excellenthelp in forum Programming
    Replies: 11
    Last Post: 06-25-2014, 07:13 AM
  4. Undefined Function
    By DS928 in forum Access
    Replies: 8
    Last Post: 07-09-2013, 03:53 PM
  5. Error:User-Define type not defined
    By A S MANN in forum Programming
    Replies: 8
    Last Post: 11-05-2011, 04:31 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