Form Generation through VBA

jacksonwearn

New member
Local time
Today, 15:45
Joined
Jun 14, 2013
Messages
9
I've been attempting to write some vba code to generate a form based on the record on a table. I'm not sure how to approach, as I'm fairly new to access. I tried using DoCmd.RunCommand acCmdNewObjectAutoForm. This seems like a good start, but I'm trying to make a tool that will generate a form for every row in a table.

I also thought about having a blank form, using vba to fill out the fields from the table and then somehow saving it as a new form. I'm not sure if this is possible. If anyone could give me some advice, or point me in the right direction it would be much appreciated.

EDIT: If the second approach is possible, it would suit my needs better. I'd like to have some command buttons on each of the forms to move back to an index form. If the forms were all generated automatically I'd have to add these buttons myself.

Another potential solution would be to create a temporary form. Again, I'm unsure if this is even possible.

Thanks
 
Last edited:
Hello welcome to AWF.. :)

Form for every record? Wow.. :eek:

Well I am not sure if you understand on how Forms and table and records interact.. A form acts as a Front end visual interpretation of the data stored in the table. A form is incapable of storing any data in it.. You have to BIND the form to a Recordsouce (a table)..

It's that or I have not understood what you are actually describing..
 
Hello welcome to AWF.. :)

Form for every record? Wow.. :eek:

Well I am not sure if you understand on how Forms and table and records interact.. A form acts as a Front end visual interpretation of the data stored in the table. A form is incapable of storing any data in it.. You have to BIND the form to a Recordsouce (a table)..

It's that or I have not understood what you are actually describing..

I'll give some more background to see if what I'm doing makes any sense. Essentially I'm making a tool to interact with (eventually) several tables that store data about part numbers and related information. I have an index page which I made from a blank form. On this page there are several combo boxes where you can select between part numbers, programs those parts are associated with, or part type.

As of now, I'm mainly just concerned with getting the part number combo box to work. I want to be able to select a part from this combo box and then have a form open up that will neatly display all of the information for that specific part number. I'll have to draw that data from the part number table, and I don't want to have to create a form for every single record that is entered.

EDIT: Maybe I could have a skeleton form, and every time a part number is selected, it unbinds any previous record set, and binds the form to the desired record set.

Hopefully that clears things up, or you can give me an idea of what I'm doing is reasonable.

Thanks again
 
Last edited:
The Combobox Wizard will do most of the heavy-lifting, here. Here's a step-by-step for doing this task:

If you haven't already done so, create a Form based on your Table or Query, including all the Fields you want displayed.

Then simply:

  • Add a Combobox to your Form.
  • The Combobox Wizard will pop up
  • Select "Find a record based on the value I selected in my combobox."
  • From the Table the Form is based on, click on the Field you're searching by (a Field that is unique for each Record) to move it to the right side.
  • Hit Next.
  • Size the column appropriately.
  • Hit Next.
  • Name the Combobox something appropriate.
  • Hit Finish.

Now you can drop the Combobox down and scroll down to the item to search by, or you can start to enter the item and the Combobox will "autofill" as you type. Hit <Enter> and the Record will be retrieved.

Linq ;0)>
 
Thanks!

This doesn't work exactly how I'd like it to, but it gets the job done.
 

Users who are viewing this thread

Back
Top Bottom