?
Solved

MS access form

Posted on 2005-04-14
13
Medium Priority
?
308 Views
Last Modified: 2007-11-27
I would like to make kind of GRID showing up on a form2 after I have clicked a button on a form1.

the grid should be based on a dynamic query( means it's programmed through Docmd command), and on the grid I need to show Employeecode, employeename,functioncode wich are from table1 and functionTitle which is in a table2.

Table1 has a relation with table2 on functioncode   1 to N   relation.


Any way, the most important is how to show a grid on MSaccess form.

thanks
0
Comment
Question by:Chuckbuchan
  • 7
  • 6
13 Comments
 
LVL 54

Accepted Solution

by:
Ryan Chong earned 1200 total points
ID: 13784336
>>Any way, the most important is how to show a grid on MSaccess form.
You can open a form in DataSheet view by adding the parameter of acFormDS on the OpenForm method, like:

DoCmd.OpenForm "MyFormName", acFormDS, , "MyField = '" & myValue & "' "

>>and on the grid I need to show Employeecode, employeename,functioncode wich are from table1 and functionTitle which is in a table2.
You can set the form's Record Source Property to a Query, where the query itself selected the fields you want to display from table1 and table2

Hope this give you some ideas on how to do it, regards
0
 

Author Comment

by:Chuckbuchan
ID: 13784693

DoCmd.OpenForm "MyFormName", acFormDS, , "MyField = '" & myValue & "' "

when I run this there is an inputbox that pops up Myfield I entered the employeecode which is 111111, it opened the form but just with an arrow on the left I clicked the arrow but it didn't show anything else, I am sure doing something wrong. Some more help..

thanks
0
 
LVL 54

Expert Comment

by:Ryan Chong
ID: 13790793
>>when I run this there is an inputbox that pops up Myfield I entered the employeecode which is 111111, it opened the form but just with an arrow on the left I clicked the arrow but it didn't show anything else

sorry, the above example shows how to open a form with filter, to open a form in datasheet with all records, try this instead:

DoCmd.OpenForm "MyFormName", acFormDS
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:Chuckbuchan
ID: 13791221
your first example is good I need the form to be opened based on a filter. The code needs some adjustment so that the form opens according to the criteria. in my example I wanted the form to be opened showing the record(s) that has as employeecode "111111"

thanks
0
 
LVL 54

Expert Comment

by:Ryan Chong
ID: 13792469
you can try like:

....
myValue = "111111"
DoCmd.OpenForm "MyFormName", acFormDS, , "employeecode = '" & myValue & "' "
....

is this works for you? regards
0
 

Author Comment

by:Chuckbuchan
ID: 13792673
I tried this code above, but it opens the form with nothing on it , just an arrow on the left , I  clicked the arrow but it didn't give anything.

the code might need some more tweaks.


thanks
0
 
LVL 54

Expert Comment

by:Ryan Chong
ID: 13792763
if no data is displayed on your form, try do this checking:

1. Make sure the Record Source is linked to a valid table/query that comes with records
2. Make sure the controls to display data is bounded to the Record Source.
3. There is employeecode that value is equals to 111111
4. what's the data type of employeecode? if it's a numeric value, try like:

....
myValue = "111111"
DoCmd.OpenForm "MyFormName", acFormDS, , "employeecode = " & myValue
....

let us know if still not working, regards
0
 

Author Comment

by:Chuckbuchan
ID: 13793646
- employeecode is a text field
- I run the query and it shows the record with employeecode=111111
- on the record source of the form "MyFormName" I put the name of the query

0
 

Author Comment

by:Chuckbuchan
ID: 13793772
actually even if I run this :
DoCmd.OpenForm "MyFormName", acFormDS

with record source of the form set to  queryname

it opens the form with nothing on it.
 
0
 
LVL 54

Expert Comment

by:Ryan Chong
ID: 13796695
>> actually even if I run this :
>>DoCmd.OpenForm "MyFormName", acFormDS
>>with record source of the form set to  queryname
>>it opens the form with nothing on it.

that means 2 possiblities:

1. make sure your controls is bouned to the Record Source

2. How is your query looks like, can you post it here.. ?

regards
0
 

Author Comment

by:Chuckbuchan
ID: 13797061
there is commandbutton1  on form1 , the onclick event for this button execute the code :
DoCmd.OpenForm "MyFormName", acFormDS.

on MyformName properties/ record source I put the query name.

the query when it's ran by itself it gives the following record

employeecode  employename  functioncode  functiontitle
111111            aaaaaa            111               doctor

 
0
 
LVL 54

Expert Comment

by:Ryan Chong
ID: 13797827
I got no more clues why it simply doesn't work at your end :/

so, can you send me a copy of your Access file to me (you can found my personal email address from my Profile), or upload it temporary to an url so that i can download it later.

regards
0
 

Author Comment

by:Chuckbuchan
ID: 13800997
I am testing the same procedure at home on Access 97, and it worked just fine, I don't know why It didn't on Access2000.

Thank you for your help.
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What do responsible coders do? They don't take detrimental shortcuts. They do take reasonable security precautions, create important automation, implement sufficient logging, fix things they break, and care about users.
When you discover the power of the R programming language, you are going to wonder how you ever lived without it! Learn why the language merits a place in your programming arsenal.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question