Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Working With CreateForm()

Status
Not open for further replies.

rgbanse

MIS
Jun 4, 2001
211
US
I want to create a form with VBA and have the ability to assign its name within the code rather than doing the Save,Close,Rename thing. I would also like to be able to assign the names to labels and text boxes within the form.
Current code follows.
thx in advance
RGB

Function NewForm()
Dim frm As Form
Dim MessageTextBox01 As Control
Dim MessageTextBox01Label As Control

Set frm = CreateForm()
frm.Width = 6480 '4.5 inches
frm.Caption = "Current Activity Display Form"
frm.AutoCenter = True
frm.AutoResize = True
frm.RecordSelectors = False
frm.NavigationButtons = False

Set MessageTextBox01Label = CreateControl(frm.Name, acLabel, , , " Current Activity ", 2450, 425, 5670, 300)
Set MessageTextBox01 = CreateControl(frm.Name, acTextBox, , , , 275, 700, 5670, 300)
frm.Text1.Enabled = False
frm.Text1.Locked = True

DoCmd.Save
DoCmd.close
DoCmd.Rename "CurrentActivityDisplay", acForm, "Form1"

DoCmd.OpenForm "CurrentActivityDisplay"
Forms!CurrentActivityDisplay.Text1 = "Message Here"
Forms!CurrentActivityDisplay.Text1.TextAlign = 2

End Function

 
Dim dbs
Set dbs = currentdb
dbs.Containers!Forms.Documents("form1").Name = "NewName"
 
Thanks for responding.
Still doesn't want to work though

Using the following

Dim dbs As Database
Dim frm As Form
Set dbs = CurrentDb
Set frm = CreateForm()
dbs.Containers!Forms.Documents("form1").Name = "NewName"
DoCmd.Save
DoCmd.close

I get compile error:
Can't assign to read only property
and it HiLites '.Name ='

thx
RGB
 
My mistake. You're right. You can get to it but not change it. I'll see what else I can come up with. Maybe something that'll work ? :)

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top