empty form

jerryczarnowski

Registered User.
Local time
Today, 11:12
Joined
Jan 29, 2012
Messages
31
Hello..first time I've used a forum..here it goes.
I have some VBA code in a click event that Creates a table then attempts to create a form with the new table as the data source. After execution, a form is created but no records are visible and the record selector shows 1 of 122. Any suggestions? I am using Access 2010 on Windows 7. Code below:

' Create a form based on tool assemblies table

Dim frmToolAssemblies As Form
Set frmToolAssemblies = CreateForm

With frmToolAssemblies
.RecordSource = "Tool Assemblies"
.Caption = "testing"
.AllowFormView = True
.DataEntry = False
End With

DoCmd.OpenForm frmToolAssemblies.Name, acFormDS
' End of form creation

DoCmd.SetWarnings True
myRecordset.Close
Set myRecordset = Nothing
Set myConnection = Nothing
End Sub
 
Hi

Never had the need to programmatically create a form myself but......... I would hazard a guess that you need to create the fields to in order to display the data and on top of that, add the source to the field.

Only a guess :)

Nidge
 
The Record Source has been set but you've not created any controls that will be bound to the fields. And if all you're doing is displaying the data in Datasheet view, why don't you just create a query and display that?

Or bind the table to a subform control and display that?
 
Thanks for the response. I have not tried binding the table to a subform control nor have I ever tried....showing my inexperience. The reason I am pursuing creating a form programmatically is that it allows the user to double click any record of a specified field...(Me."Fieldname".Value) and execute event code pertaining to the business. If I run a query or view the newly created table in datasheet view, I cannot utilize VBA...or can I?. Basically I am trying to programmatically create a table from multiple tables, create a form from the new table, and assign custom queries to command buttons on the new form. Am I in the ballpark or way off? Any help is greatly appreciated.
 
I don't see any need for creating a form on the fly. Create a template form that contains a subform in it, set the Source Object of the subform control programatically, pre-code buttons you've placed on the main form.
 
Thanks vbaInet...I will do my homework on template forms and subforms and give it a try.
 
It's much more manageable that way and less coding and compile effort.

Let us know how you get on.
 

Users who are viewing this thread

Back
Top Bottom