By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,477 Members | 1,602 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,477 IT Pros & Developers. It's quick & easy.

How to create Button in access form from VBA

100+
P: 222
Dear expert;

using access 2003 .

I have a table name "tables" that contains "tableid" & "tabledesc"

The idea is to design a form that contains for each record in "tables-->tableid" a button and each time user add a new record in tableid a new button will be created.

I was thinking to add the button through VBA on form open..

Any idea about that. ?

Thank you in advance;

WASSIM S DACCACHE;
May 19 '08 #1
Share this Question
Share on Google+
5 Replies


Expert 100+
P: 112
It sounds like what you want to do is make a continuous form. You can use the form wizard to do this or you can setthis from the properties of the form. Set the recordsource of your form to the table and drag the relevant fields into the detail section of the form, place a button in the detail section of the form and you will have a button for every record.
May 19 '08 #2

100+
P: 222
It sounds like what you want to do is make a continuous form. You can use the form wizard to do this or you can setthis from the properties of the form. Set the recordsource of your form to the table and drag the relevant fields into the detail section of the form, place a button in the detail section of the form and you will have a button for every record.
Man actually what I need is this form attached.

and they asked me to do it each 5 records related to the tableid on a single line or next each other
Attached Files
File Type: zip form.zip (53.9 KB, 234 views)
May 20 '08 #3

Expert 100+
P: 112
I'm a little confused by your request, do you want to be able to select one of the buttons and see all the related table_id records along with a button for each?
May 20 '08 #4

100+
P: 222
I'm a little confused by your request, do you want to be able to select one of the buttons and see all the related table_id records along with a button for each?
Thank you for your quick reply,

Ok let me expand what I am really thinking about.

I am trying to design a database for a restaurant. My boss asked to have a main form contains the number of table in restaurant. it means records "table_id".

The problem is--> he needs to group every 5 buttons in a single line. When I tried to make a continuous form all records was expanded in vertical way.

Is there any method in access to group a continuous form "ex: 5 records" (each line?
if not what I was thinking about is to have a module that count me the record on table and create buttons from VBA...

Please suggests to proceed.

BEST REGARDS;

WASSIM S DACCACHE
May 21 '08 #5

Expert 100+
P: 112
My assumptions about what you want are:
1. You have a table with all of the tables (the real kind that people eat at) which each have a table_id.
2. You want to be able to group these table_ids into groups of five and have a button that corresponds to each table within the group.
3. When you press that button something relevant to the corresponding table happens.

If I were you, what I would do, is associate a group field within in the table of tables. For instance every table in group1 should have a corresponding value in the group field of 'group1' so:

Table_id | Group
1 Group1
2 Group1
3 Group1
4 Group1
5 Group1
6 Group2
And so forth.

I would use a continuous form with this table as the rowsource.
I would then populate a control with the distinct values of this table (I usually use comboboxes for this purpose but that's just my preference) so the row source for this control would be:
SELECT DISTINCT Group FROM tblTables (whatever your table is called)
When the user changes the value in this combox set the form's filter to whatever is in the combobox. I am shying away from telling you to add button via vba (i'm not sure if this is possible in access forms I know it is in forms 2.0 but not sure about access) but it is also a nightmare to keep up with all that overhead when it sounds like most of the functionality you need is already built into access.
Let me know if you have questions I'd be glad to help.
May 21 '08 #6

Post your reply

Sign in to post your reply or Sign up for a free account.