Results 1 to 9 of 9
  1. #1
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496

    Tempvars replace formname

    I have a form that opens with onclick()



    vba is

    tempvars.add "theformclose", form.name

    then on another form I have

    Private Sub Form_Close()
    Dim exform As String
    exform = TempVars!theformclose


    End Sub

    I wanted to add before the end sub "forms!theformclose.form.refresh"

    but access reads it not as the dim but looks for the form

    way around it in keeping with what I am trying to achieve?

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,822
    Using variables in references is different from using literals.

    Try:

    Forms(theformclose).Refresh

    If the variable is theformclose, then why do you need exform?

    I've never used TempVars.
    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.

  3. #3
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    Quote Originally Posted by June7 View Post
    Using variables in references is different from using literals.

    Try:

    Forms(theformclose).Refresh

    If the variable is theformclose, then why do you need exform?

    I've never used TempVars.

    It's more of an experiment - you can have two forms open to another form, when that form closes it refreshes which ever of the two was the one to open it.

    Thanks June I will give that a try

    Also using () gets around a few things I suppose?

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,822
    Not sure what you mean by 'gets around'. I just know syntax is different with variables. I suppose this would also work:

    Forms("literal form name").Refresh

    or maybe

    Forms(Me.Name).Refresh

    Just looked at your code again. Does Form.Name actually work?
    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
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    Quote Originally Posted by June7 View Post
    Not sure what you mean by 'gets around'. I just know syntax is different with variables. I suppose this would also work:

    Forms("literal form name").Refresh

    or maybe

    Forms(Me.Name).Refresh

    Just looked at your code again. Does Form.Name actually work?
    form.name does work - I made it display from a string just to check.

  6. #6
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    why don't you just check to see if the form is open and updated it if it is?

    Code:
    If CurrentProject.AllForms("FormName").IsLoaded Then
        MsgBox "open"
    Else
        MsgBox "no open"
    End If

  7. #7
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    if you want to see if the form is actually in form view you could do this too:

    Code:
    If SysCmd(acSysCmdGetObjectState, acForm, "formname") <> 0 Then
        If Forms("formname").CurrentView <> 0 Then
            IsFormLoaded = True
        Else
            IsFormLoaded = False
        End If
        End If

  8. #8
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    Quote Originally Posted by rpeare View Post
    if you want to see if the form is actually in form view you could do this too:

    Code:
    If SysCmd(acSysCmdGetObjectState, acForm, "formname") <> 0 Then
        If Forms("formname").CurrentView <> 0 Then
            IsFormLoaded = True
        Else
            IsFormLoaded = False
        End If
        End If

    I will use what you have in post 6, but what scenario would you use what you have in post 7?

  9. #9
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    the isloaded will return true even if the form is in design view.

    Checking the object state you can determine if it's in form view (i.e. ready for data entry), in practical terms for your application it may not mean much because your users won't be looking at the design view and should only have open forms you would just do whatever you want in the "TRUE" part of of post 7 instead of setting a true/false flag.

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

Similar Threads

  1. TempVars.add and make value ID
    By Ruegen in forum Programming
    Replies: 4
    Last Post: 12-31-2013, 06:19 PM
  2. Replies: 3
    Last Post: 06-07-2012, 07:05 AM
  3. Replies: 5
    Last Post: 12-05-2011, 05:35 AM
  4. Using TempVars in query
    By jonesy29847 in forum Programming
    Replies: 3
    Last Post: 03-03-2011, 11:07 PM
  5. forms![FormName].repaint ?
    By markjkubicki in forum Programming
    Replies: 2
    Last Post: 09-24-2010, 01:27 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