Export contents of a form

mdusoe

Active Member
Joined
Aug 27, 2004
Messages
428
Is there a way to export a form object, out of the VBE, into a .bas file or something?

What I am trying to do is to store the various Forms and Reports in a Version Control Manager (VCM) (Source Safe, most probably). But if I try to put the whole .mdb file into the VCM, it doesn't do me much good.

Any thoughts?

Thanx,
Mike.
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
There is an add-in that comes with Microsoft Office Developer Edition that allows you to save code. Not certain you can save forms.


(text from the option on my machine)
Use the VBA Source Code Control Add-in to take advantage of the Microsoft Visual SourceSafe source code control tool from within the Visual Basic for Applications 6.0 IDE.
 
Upvote 0
Hmmmm, not sure if that is an option. It would require upgrading to the Developer Edition, and given our current situation at the office, I don't know if that is possible...

I will explore it, but are there any other suggestions?

Thanx,
Mike.
 
Upvote 0
I was poking around on my installation - for some quirky reason that I never bothered to figure out, I can't get Visual Sourcesafe installed on my work PC...but, looking at the docs, it's very clear it's designed to allow you to check in/out ALL objects in the database.

Your best and possibly only route to do this may be the Office Developer edition. There was also a Developers Tools (only) addition you might try. Office Developer is a Premium Office package + tools.

You might try something like this next code snippet. I was recently, on my own, playing around with itemizing all controls and objects on a form just in case I wanted to automate some sort of form rebuild process.

Code:
Sub ShowFormStuff()
Dim dbs As DAO.Database
Dim rs, rsR As DAO.Recordset
Dim strSQL As String
Dim x, y As Integer

Set dbs = CurrentDb

strSQL = "DELETE * FROM tblControls"
DoCmd.RunSQL strSQL
strSQL = "SELECT * from tblControls"
Set rs = dbs.OpenRecordset(strSQL, dbOpenDynaset)
strSQL = "SELECT * FROM tblProperty"
'Set rsR = dbs.OpenRecordset(strSQL, dbOpenDynaset)

Set rsR = dbs.OpenRecordset(strSQL, dbOpenDynaset)

With rs
  For x = 0 To Forms!frmSelect.Controls.Count - 1
  .AddNew
    'Debug.Print Forms!frmSelect.Controls.Item(x).Name
    .Fields(0).Value = Forms!frmSelect.Controls.Item(x).Name
    .Update
      For y = 0 To Forms!frmSelect.Controls.Item(x).Properties.Count
       'Debug.Print Forms!frmSelect.Controls.Item(x).Properties(y).Name & " " _
            ; Forms!frmSelect.Controls.Item(x).Properties(y).Value & " End Entry"
       Set rsR = dbs.OpenRecordset(strSQL, dbOpenDynaset)
       rsR.AddNew
       rsR.Fields(0).Value = Forms!frmSelect.Controls.Item(x).Name
       If Not IsNull(Forms!frmSelect.Controls.Item(x).Properties(y).Name) Then
         rsR.Fields(2).Value = Forms!frmSelect.Controls.Item(x).Properties(y).Name
       End If
       If Not IsNull(Forms!frmSelect.Controls.Item(x).Properties(y).Value) And _
         Len(Forms!frmSelect.Controls.Item(x).Properties(y).Value) > 0 Then
         rsR.Fields(3).Value = Forms!frmSelect.Controls.Item(x).Properties(y).Value
       End If
       rsR.Update
    Next y
  Next x
End With

End Sub

I should add the above populates two related tables. I was looking to build lists. I tossed my error handling but it's buggy and does hit some errors with null values in properties.

Mike
 
Upvote 0

Forum statistics

Threads
1,223,692
Messages
6,173,860
Members
452,535
Latest member
berdex

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top