create a userform

sambrierley

Registered User.
Local time
Today, 07:31
Joined
Apr 24, 2014
Messages
56
hi all,

i would of thought this was dead easy.

can anyone provide the syntax for vba to create a userform with a variable as the source?

i dont want anything fancy simply replicate opening a table and clicking the form button.

thanks

quick edit - p.s i can use this to create a form with the source, im sorry what im after is all of the columns in the source being put into the form. the tables change and i dont fancy making a form for each hence the requirement.
<CODE>
Sub NewForm()

Dim frm As Form

'Create a new form based on the XXXXX form
Set frm = CreateForm(, "192_csv")
DoCmd.Restore

frm.RecordSource = "192_csv"

End Sub <CODE>
 
you don't need code to do this , just press the form button, boom, form.
the button it will even make a form w fields, connected to a table/query.
no code needed.
 
hi Ranman,

thanks however that's not what i want to do, i want simply a piece that when triggers performs that action for the user and the results are the same.
 
I didn't understand a lot of what you were trying to say, but this stuck out:

the tables change and i dont fancy making a form for each hence the requirement.

Tables, shouldn't change in a properly structured database. I think you need to focus more on your tables/fields than on your forms at this point. My gut tells me you are stroing relevant information in table and field names (e.g. SalesMay2016, SalesJune2016, etc.)

Can you explain why your tables/fields change?
 
ok...

i have a userform that is attached to a table, standard stuff.
as the user scrolls through the records sometimes a record will say "Refer to table X".

what i currently do is this..

If InStr(Me.Heading_5, "Ref to table") > 0 Then
TableName = Me.Requirement_Number & "_csv" 'this is the table name
DoCmd.OpenTable TableName, acNormal
End If

what i want is to make it more user friendly i want to create the appropriate userform which can be destroyed when the user is finished.

unfortunately all of the table x's are completely different.

does that make a little more sense?
 
TableName = Me.Requirement_Number & "_csv" 'this is the table name

Does each of these tables have the same structure? If so, I was right and you need to get your data in order. Instead of having the form open a specific table, you would apply a filter to the form to just show the records you want.

Let's use my sales example from before (SalesMay2016, SalesJune2016). You wouldn't have a table for each month, then try and have the form open the right sales table. You would have one table (Sales) and in that table you would have a field to designate what month/year the sales are for (SalesMonth, SalesYear). Then if you only wanted to work with May 2016's data, you would apply a filter to your form and show just May 2016 values.

You need to fix your data first.
 
Hi Plog,

unfortunately no the tables are completely different, they are no way related.

i understand what your getting at but unfortunately will not work.

its looking as though simply automating clicking that button isnt possible.
 

Users who are viewing this thread

Back
Top Bottom