Hi
I am new in Ms Access
I need to know how can i create a command button on a form. When it is clicked, a table is opened that is associated to the data in a field i have.
E.g: if ( surName == "abc") then open table Table_Abc
if ( surName == "qaz") then open table Table_Qaz
i will have a lot of surnames, so tables needs to be opened accordingly.
Will it be done by macro, or expressin builder? If it needs VB code, can you give me that as i dont know VB
thank you very much
hassan
24 5314
Do you need a seperate table for each surname? It may be easier to create a query that filters for the surname and then open the query. To open a query you use the code: - DoCmd.OpenQuery "Name of Query"
Do you need a seperate table for each surname? It may be easier to create a query that filters for the surname and then open the query. To open a query you use the code: - DoCmd.OpenQuery "Name of Query"
yes i need seperate tables.. how can i do it then?
yes i need seperate tables.. how can i do it then?
Why do you need seperate tables?
The code to open a table for your naming convention would be: - DoCmd.OpenTable "Table_" & Surname
Why do you need seperate tables?
The code to open a table for your naming convention would be: - DoCmd.OpenTable "Table_" & Surname
What will keyword Table_ do?
will i have to re-write this line of code for every surname?
i have different tables that contains details (more than 5 rows) of every surname.
is there any better way doing it than having seperate tables?
thanks a lot
What will keyword Table_ do?
will i have to re-write this line of code for every surname?
i have different tables that contains details (more than 5 rows) of every surname.
is there any better way doing it than having seperate tables?
thanks a lot
"Table_" is not a keyword. I assumed you used the format Table_ Surname to name all your tables. "Table_" & Me.Surname.Value will return the string Table_ Surname assuming that Surname is a control on your form.
What details of the surname are you storing? One way to keep all the data centralized is to have a field that designates which surname the record belongs to.
Take a look at Normalisation and Table Structures, it will help you structure your tables.
"Table_" is not a keyword. I assumed you used the format Table_Surname to name all your tables. "Table_" & Me.Surname.Value will return the string Table_Surname assuming that Surname is a control on your form.
What details of the surname are you storing? One way to keep all the data centralized is to have a field that designates which surname the record belongs to.
Take a look at Normalisation and Table Structures, it will help you structure your tables.
thanks i am getting undertanding now.
What is Me keyword? will it be the name of the form? I have written this code and getting an error: "method or data member not found". ?
DoCmd.OpenTable "Table_" & Me.surName_Label.Value
thanks i am getting undertanding now.
What is Me keyword? will it be the name of the form? I have written this code and getting an error: "method or data member not found". ?
DoCmd.OpenTable "Table_" & Me.surName_Label.Value
I thought that surname_Label was wrong. this now code. Also i changed Me to Form (the name of the form)?
DoCmd.OpenTable "Table_" & Form.surName.Value
but now when i run i get error: .. cant find object Table_surName1.
surName1 is a table i have created. why it cant find it?
thanks i am getting undertanding now.
What is Me keyword? will it be the name of the form? I have written this code and getting an error: "method or data member not found". ?
DoCmd.OpenTable "Table_" & Me.surName_Label.Value
1. The Me. refers to the current form.
2. You cannot use .Value on a label, thy the following -
DoCmd.OpenTable "Table_" & Me.surName_Label.Caption
Mary
1. The Me. refers to the current form.
2. You cannot use .Value on a label, thy the following -
DoCmd.OpenTable "Table_" & Me.surName_Label.Caption
Mary
But i have tried this:
DoCmd.OpenTable "Table_" & Detail.surName.Value
surName is Text Box
Detail is the Detail portion where the surName TextBox is - under the Header
I get following error now: Method or Data Value not found?
Please help.
But i have tried this:
DoCmd.OpenTable "Table_" & Detail.surName.Value
surName is Text Box
Detail is the Detail portion where the surName TextBox is - under the Header
I get following error now: Method or Data Value not found?
Please help.
Try ... - DoCmd.OpenTable "Table_" & Me.surName
Try ... - DoCmd.OpenTable "Table_" & Me.surName
now i get a different error:
'.. cant find the object Table_detail1'
i have a surname value 'detail1' and have also a table called 'detail1', so there should be any error generated ?
now i get a different error:
'.. cant find the object Table_detail1'
i have a surname value 'detail1' and have also a table called 'detail1', so there should be any error generated ?
If the table is called 'detail1', you don't need the 'Table_' part, just ... - DoCmd.OpenTable Me.surName
If the table is called 'detail1', you don't need the 'Table_' part, just ... - DoCmd.OpenTable Me.surName
That worked. thanks
by the way. would you tell me why was i actually told to use 'Table_' .. when do we need this?
That worked. thanks
by the way. would you tell me why was i actually told to use 'Table_' .. when do we need this?
Rabbit was talking about naming conventions. By convention tables are named Table_Name or tblName.
Mary
Rabbit was talking about naming conventions. By convention tables are named Table_Name or tblName.
Mary
Ok
Now if i want to open detail1 table in a form.. I know i need to create a form first.
But there are many tables e.g detail1, detail2, etc ... but all have exactly similar fields.
How will i set it..... open a form that will actually be opening appropriate table i.e detail1, detail2, etc ?
Ok
Now if i want to open detail1 table in a form.. I know i need to create a form first.
But there are many tables e.g detail1, detail2, etc ... but all have exactly similar fields.
How will i set it..... open a form that will actually be opening appropriate table i.e detail1, detail2, etc ?
You need to change the record source of the form each time. In the forms On load event put the following code: -
Private Sub Form_Load()
-
-
' Replace FormName with the name of the Form with the surName textbox.
-
Me.RecordSource = Forms![FormName]![surName]
-
-
End Sub
Mary
You need to change the record source of the form each time. In the forms On load event put the following code: -
Private Sub Form_Load()
-
-
' Replace FormName with the name of the Form with the surName textbox.
-
Me.RecordSource = Forms![FormName]![surName]
-
-
End Sub
Mary
I cant find the ' On Load' event. it is not in the form properties box ?
I cant find the ' On Load' event. it is not in the form properties box ?
It should be under the event tab. Scroll down. It's definitely there.
Mary
It should be under the event tab. Scroll down. It's definitely there.
Mary
OnLoad event would be in the properties of the form, not of the button, right?
And It is not there under the Even Tab..
how can i attach an image with this message? the attach an image button prompts me and asks to enter text to be formatted- what is that
i dont know if i am gonig totally wrong. but under the event tab ,on load is not present?
OnLoad event would be in the properties of the form, not of the button, right?
And It is not there under the Even Tab..
how can i attach an image with this message? the attach an image button prompts me and asks to enter text to be formatted- what is that
i dont know if i am gonig totally wrong. but under the event tab ,on load is not present?
Are you sure you are in the forms properties. Does it say Form in the Blue Bar at the top of the properties box?
Mary
Are you sure you are in the forms properties. Does it say Form in the Blue Bar at the top of the properties box?
Mary
. My form is called 'names'.. so it says on the Blue bar: 'names: Form' . And the properties box says ' Section: Detail' - this text 'Secion: Detail' remains same no matter what the form is called.
Is there any way i can go directly into the code input area and type in the required code?
. My form is called 'names'.. so it says on the Blue bar: 'names: Form' . And the properties box says ' Section: Detail' - this text 'Secion: Detail' remains same no matter what the form is called.
Is there any way i can go directly into the code input area and type in the required code?
I am sorry, i have found OnLoad now. It was under 'Form'.. i was looking under the 'Detail'.
But with On Load code , there comes another confusion.
Previously, you had given me a code so that when the button is pressed, an appropriate table is opened (the same as the surName).. it worked fine!
But the On Load code, i have now put in the form's(called 'details') On Load property. This form need to be opened when the command button is pressed (on the main form).
But the table the 'details' form will use to get data will be different all the times (different with different surname!) ... so where would i put the OnLoad code?
i have tried putting onLoad code in the 'details' form's OnLoad property, but nothings happens... When i press the button, appropriate tables are opened -not the 'details' form ??
Thanks
I am sorry, i have found OnLoad now. It was under 'Form'.. i was looking under the 'Detail'.
But with On Load code , there comes another confusion.
Previously, you had given me a code so that when the button is pressed, an appropriate table is opened (the same as the surName).. it worked fine!
But the On Load code, i have now put in the form's(called 'details') On Load property. This form need to be opened when the command button is pressed (on the main form).
But the table the 'details' form will use to get data will be different all the times (different with different surname!) ... so where would i put the OnLoad code?
i have tried putting onLoad code in the 'details' form's OnLoad property, but nothings happens... When i press the button, appropriate tables are opened -not the 'details' form ??
Thanks
Mary..i have done it . it is working..
i put this code for the command button:
DoCmd.OpenForm "details"
and in the 'details' form onLoad properties, i put the code you have provided me
Thanks a lot..
I am sorry, i have found OnLoad now. It was under 'Form'.. i was looking under the 'Detail'.
But with On Load code , there comes another confusion.
Previously, you had given me a code so that when the button is pressed, an appropriate table is opened (the same as the surName).. it worked fine!
But the On Load code, i have now put in the form's(called 'details') On Load property. This form need to be opened when the command button is pressed (on the main form).
But the table the 'details' form will use to get data will be different all the times (different with different surname!) ... so where would i put the OnLoad code?
i have tried putting onLoad code in the 'details' form's OnLoad property, but nothings happens... When i press the button, appropriate tables are opened -not the 'details' form ??
Thanks
You need two pieces of code.
One for the command button to open the details form and the second one for the On Load event of the details form to change the record source to the table chosen in the previous form.
Make sure the Details form is set to Form view and not datasheet view.
Mary
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Nathan Bloom |
last post by:
Is there a way to force the user of a database to exit and close access
through a close button on for example a switchboard menu?
If a user closes access by the exit command or the close button...
|
by: Colleyville Alan |
last post by:
I have been working on an Access app that takes info from a file and writes
it to a spreadsheet on a form, simultaneously saving the spreadsheet to
Excel. I got the idea that the same concept...
|
by: Yannick Turgeon |
last post by:
Hello,
We are in the process of examining our current main application. We have to
do some major changes and, in the process, are questionning/validating the
use of MS Access as front-end. The...
|
by: Ron B |
last post by:
Help!!!
What am I doing wrong? I am working with Office 2003 and am trying to create a command button on an Access form that will create a mail merge in Word from an Access table.
I want to...
|
by: Dököll |
last post by:
Jumped for joy last night after learning, indeed, the command button wizard can be switched on or off. Well this occured here, with my Access 2000...an attempt to redo at work failed.
Here's the...
|
by: CoolFactor |
last post by:
MY CODE IS NEAR THE BOTTOM
I want to export this Access query into Excel using a command button on an Access form in the following way I describe below.
Below you will find the simple query I am...
|
by: hyperpau |
last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding.
I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com).
Ergo, I...
|
by: zufie |
last post by:
I have a main form containing a command SEND button that prompts an
email form to pop up.
The email address(es) that are supposed to appear on the email form
are those corresponding to the...
|
by: Tony |
last post by:
I am continuing to develop an Access 2007 application which was
originally converted from Access 2003. In Access 2003 I was able to
disable the Access Close button in the top righthand corner of...
|
by: Tony |
last post by:
I am continuing to develop an Access 2007 application which was
originally converted from Access 2003. In Access 2003 I was able to
disable the Access Close button in the top righthand corner of...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |