dim string to dim form 
Author Message
 dim string to dim form

'  I am trying to list all the controls on all of the forms on a database
'  I am inserting the name of the form; its caption and the control name and control tip text properties in a table
'  my problem is with the inner loop of my function
'  frm has to be a form in order to get the desired results
' Any tips? problems marked in red; thanks

Function DisplayFormInformation()

Dim frm As Form
Dim strObject As String, aob As AccessObject, obj As Object
Dim strTemp As String, strList As String
Dim strTempForm As Variant
Dim myObject As Object
Dim k As Long
Dim frmControl As Control
Dim frmControls As Controls

Dim ConnectToDB As New ADODB.Connection
Set ConnectToDB = CurrentProject.Connection

Dim rTarget As New ADODB.Recordset
rTarget.Open "ObjectDocumenter", ConnectToDB, adOpenKeyset, adLockOptimistic

        Set obj = CurrentProject.AllForms

On Error Resume Next

  For Each aob In obj
    strTemp = aob.Name
    DoCmd.OpenForm strTemp, acDesign
    strTempForm = "forms!" & strTemp
    Set frm = strTempForm

              For Each frmControl In frm.Controls

                rTarget.AddNew
                    rTarget("FormName") = strTemp
                    rTarget("FormCaption") = Eval("forms!" & strTemp & ".caption")
                    rTarget("ObjectName") = frmControl.Name
                    rTarget("ControlTipTextValue") = frmControl.ControlTipText
                rTarget.Update

    Next frmControl
    DoCmd.Close acForm, strTemp

  Next

  rTarget.close
  ConnectToDB.close

 End Function



Tue, 27 Apr 2004 09:05:25 GMT  
 dim string to dim form
Try the following syntax

'    strTempForm = "forms!" & strTemp commented out
    Set frm = Forms(strTemp)

              For Each frmControl In frm.Controls

Duane


'  I am trying to list all the controls on all of the forms on a database
'  I am inserting the name of the form; its caption and the control name and
control tip text properties in a table
'  my problem is with the inner loop of my function
'  frm has to be a form in order to get the desired results
' Any tips? problems marked in red; thanks

Function DisplayFormInformation()

Dim frm As Form
Dim strObject As String, aob As AccessObject, obj As Object
Dim strTemp As String, strList As String
Dim strTempForm As Variant
Dim myObject As Object
Dim k As Long
Dim frmControl As Control
Dim frmControls As Controls

Dim ConnectToDB As New ADODB.Connection
Set ConnectToDB = CurrentProject.Connection

Dim rTarget As New ADODB.Recordset
rTarget.Open "ObjectDocumenter", ConnectToDB, adOpenKeyset, adLockOptimistic

        Set obj = CurrentProject.AllForms

On Error Resume Next

  For Each aob In obj
    strTemp = aob.Name
    DoCmd.OpenForm strTemp, acDesign
    strTempForm = "forms!" & strTemp
    Set frm = strTempForm

              For Each frmControl In frm.Controls

                rTarget.AddNew
                    rTarget("FormName") = strTemp
                    rTarget("FormCaption") = Eval("forms!" & strTemp &
".caption")
                    rTarget("ObjectName") = frmControl.Name
                    rTarget("ControlTipTextValue") =
frmControl.ControlTipText
                rTarget.Update

    Next frmControl
    DoCmd.Close acForm, strTemp

  Next

  rTarget.close
  ConnectToDB.close

 End Function



Mon, 26 Apr 2004 11:14:49 GMT  
 dim string to dim form
You are close.  Try:

    Set frm = Forms.Item(strTemp)

or even shorter

    Set frm = Forms(strTemp)

(since Item is the Default Property of Forms).

BTW, please use PlainText for posting as PlainText is faster for everyone to
download.  Also, check you PC date, you are 1 day too early.  Lots of
potential responders won't reply to post-dated questions.  Check the
netiquette available from:

http://www.mvps.org/access/netiquette.htm

HTH
Van T. Dinh


'  I am trying to list all the controls on all of the forms on a database
'  I am inserting the name of the form; its caption and the control name and
control tip text properties in a table
'  my problem is with the inner loop of my function
'  frm has to be a form in order to get the desired results
' Any tips? problems marked in red; thanks

Function DisplayFormInformation()

Dim frm As Form
Dim strObject As String, aob As AccessObject, obj As Object
Dim strTemp As String, strList As String
Dim strTempForm As Variant
Dim myObject As Object
Dim k As Long
Dim frmControl As Control
Dim frmControls As Controls

Dim ConnectToDB As New ADODB.Connection
Set ConnectToDB = CurrentProject.Connection

Dim rTarget As New ADODB.Recordset
rTarget.Open "ObjectDocumenter", ConnectToDB, adOpenKeyset, adLockOptimistic

        Set obj = CurrentProject.AllForms

On Error Resume Next

  For Each aob In obj
    strTemp = aob.Name
    DoCmd.OpenForm strTemp, acDesign
    strTempForm = "forms!" & strTemp
    Set frm = strTempForm

              For Each frmControl In frm.Controls

                rTarget.AddNew
                    rTarget("FormName") = strTemp
                    rTarget("FormCaption") = Eval("forms!" & strTemp &
".caption")
                    rTarget("ObjectName") = frmControl.Name
                    rTarget("ControlTipTextValue") =
frmControl.ControlTipText
                rTarget.Update

    Next frmControl
    DoCmd.Close acForm, strTemp

  Next

  rTarget.close
  ConnectToDB.close

 End Function



Mon, 26 Apr 2004 20:02:59 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Newbie Question: Dim A() as String /Dim A as String()

2. Dim obj As New Class crt Dim Obj As Class = New Class

3. dynamically dim a variable ie dim "variable"&n

4. dim myObject as Object versus dim myObject as myProject.class1

5. dim myObject as Object versus dim myObject as myProject.class1

6. dim forms(x to y) as form

7. Dim pages(,) As String?

8. Dim for strings ? (qbasic)

9. Odd Behavior re: dim as string and then input

10. Efficient use of strings (Dim, Redim, and all that)

11. Dim xxxx AS String * 30

12. Dim a Variable from a string???Possible??

 

 
Powered by phpBB® Forum Software