Results 1 to 11 of 11
  1. #1
    Join Date
    May 2019
    Posts
    65

    TempVars not working with Type - Double

    This is a button on a form which contains the control "ShelterNumber". In the table this is a Double variable. With this function I want to get the Name of the form I'm on before leaving. (This works)
    But I'm also trying to get the ShelterNumber and I keep getting the error Object Required. I've tried various syntax and nothing seems to work.

    Here is the CODE

    Function CallButton()


    'What is the name of the form that called this function

    Dim CallingForm As String
    Dim GotoRecord As Double
    strSubFormName = Screen.ActiveControl.Parent.Name

    TempVars!CallingForm = strSubFormName' THIS WORKS



    TempVars!GotoRecord = ShelterName.Value 'THIS DOESN'T


    MsgBox TempVars!CallingForm
    MsgBox (TempVars!GotoRecord)

    Exit Function

    End Function


    END OF CODE

    Thanks in advance for any help.
    Sorry about the indent, this is still in progress.

  2. #2
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    TempVars is a collection of objects. You have an object named GoToRecord in that collection? If so, I'd say you should not be using the name of a method that belongs to the DoCmd object. Regardless, the issue is likely that you have not associated an object (form) to ShelterName. It would be like me telling you to go to house number 154 without giving you the name of the street. You would need to at least preface that with Me, but I can't tell if you ought to be using the Forms! reference instead.
    EDIT - could even be strSubFormName or CallingForm? Can't tell what's what so...
    Also, to retain indentation and formatting of code, enclose code in code tags (# on forum toolbar)
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    Join Date
    May 2019
    Posts
    65
    Hi,
    Thanks for the quick response.
    I'm not sure what you meant when you asked the question - Do I have a GotoRecord in my objects? Assuming you meant that it was duplicated elsewhere or part of a method for a DoCmd, I changed the name and it didn't make any difference.
    I also tried the me.shelternumber.value and it gave me an error of "Invalid use of the word Me".
    I have tried various syntaxes for the forms.
    frmSCD.navigationsubform > frmShelterMain.ShelterNumber.value
    frmShelterMain.ShelterNumber.Value
    and haven't got that right.

    If I substitute a number vallue, like 13359, the tempvars!gotorecord = 13359 works.
    I just can't get the value from the shelternumber control.

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,822
    You say you want ShelterNumber yet code refers to ShelterName.

    GoToRecord is an intrinsic command. If you had a TempVars named GoToRecord, that might cause confusion to VBA - or might not.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    Join Date
    May 2019
    Posts
    65
    Quote Originally Posted by June7 View Post
    You say you want ShelterNumber yet code refers to ShelterName.

    GoToRecord is an intrinsic command. If you had a TempVars named GoToRecord, that might cause confusion to VBA - or might not.
    I changed the tempvar from GoToRecord to Sloppy and the same thing happened. Also, the code should read ShelterNumber. I just was trying a string variabl instead of a double
    and forgot to change that part of the code back.

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,822
    If you want to provide db for analysis, follow instructions at bottom of my post.

    I've never used TempVars but I know what they are.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    "Invalid use of the word Me".
    That tells me the code is not on the form you're trying to reference. Explain how the forms are built to work together and what their names are. For example, MySubform is a subform on a main form named MyMainForm and the control is on the subform (or main form). If this is about a subform on a main form, we need to know the subform control name. It may or may not be the same name as the subform itself.

  8. #8
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,016
    Quote Originally Posted by Micron View Post

    That tells me the code is not on the form you're trying to reference.
    It's in a Function.

    Linq ;0)>
    Last edited by Missinglinq; 12-16-2019 at 01:24 PM.
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  9. #9
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    Quote Originally Posted by Missinglinq View Post
    It's in a Function.
    Liq ;0)>
    I don't get your point. If the function is on the form, you can use Me. If it's not, you can't.
    That's my point.

  10. #10
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,016
    And I was just supporting your point...by pointing out that it was in a Function...presumably in a Module...not in a Form...although anything is possible, I suppose!

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  11. #11
    davegri's Avatar
    davegri is online now Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,389
    Jeff, too much confusion here about what your form structure is, where the submitted code resides, which form the controls are on, and others.
    I think you need to consider June's suggestion in post #6 and submit your DB here.

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

Similar Threads

  1. Working with a Double Query on a a Form
    By Lou_Reed in forum Access
    Replies: 92
    Last Post: 06-03-2017, 10:59 AM
  2. Replies: 2
    Last Post: 10-09-2016, 06:46 AM
  3. Field Type of type-Double/Float
    By McArthurGDM in forum Access
    Replies: 3
    Last Post: 12-10-2014, 01:54 PM
  4. changing multiple fields type to double
    By neefbeef in forum Access
    Replies: 1
    Last Post: 12-07-2014, 03:20 AM
  5. Replies: 3
    Last Post: 05-31-2013, 04:32 PM

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