creating form using VBA

keyur

Registered User.
Local time
Today, 08:17
Joined
Jun 22, 2004
Messages
41
Hi

Is it possible to create a form (like when you use the wizard) using VBA?

Thanks
 
Yes, it is possible to create a form (like when you use the wizard) using VBA.
 
Thanks, byte... if you know could you please tell me how? :)
 
The following example code creates a new form, adds a TextBox control named txtCtrl and saves the form as MyTestForm.

Code:
Public Function AddForm()

    Dim frm As Form, oldName As String, frmCtrl As Control
    
    Set frm = CreateForm
    oldName = frm.Name
    
    Set frmCtrl = CreateControl(frm.Name, acTextBox, , "", "", 100, 100, 1440, 240)
    frmCtrl.ControlName = "txtCtrl"
    DoCmd.Close acForm, frmName, acSaveYes
    Set frm = Nothing
    DoCmd.Rename "MyTestForm", acForm, oldName

End Function
 
Thanks byte. but i already new that method. i meant can we make a form from based on the existing table. I have a table in which the fields can be added or deleted by the user. so i dont want them to go to wizard, every time this happens, to create a form for edited table. I hope u understand what i am trying to get here.

Thanks again.
 
keyur said:
I have a table in which the fields can be added or deleted by the user.

WHY? That's NOT right at all. :eek:
 
dont get shocked. by user i mean almost like administrator. the database i am making is for someone who's not to familiar with it. and there's a long story.... so i am trying to make that person's job easier.

thanks for your help and concern :)
 
I still don't understand why you don't make a robust structure so that there is no need to add and delete fields from a table. Doing such a thing would necessitate the editing of all queries that make use of these tables too. Deleting a field from a table which is used in a query will result in parameter boxes popping up all over the shop trying to get a vlue for the missing fields.

Personally, I think you treading a dangerous path. ;)
 

Users who are viewing this thread

Back
Top Bottom