473,324 Members | 2,124 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

Need help with a form

84
I created a form that when it is open the results of a query are displayed in a text box. I created a event procedure that when you double click on an item in the text box the ID of the item is passed to another query and the results of that query will appear on a new screen. I was wondering is there a way to get the system to display the results of the query in another text box on the same form screen as the original text box. Any help or hints would be greatly appreiciated.
Mar 2 '07 #1
6 1341
MSeda
159 Expert 100+
create a subform on the main to display the results of the second query. you will need to requery the sub form after the user make the selection on the main form.
Mar 3 '07 #2
sesling
84
create a subform on the main to display the results of the second query. you will need to requery the sub form after the user make the selection on the main form.
For clarification, in my first post I said the results of my query appear on the main form in a text box. They actually appear in a list box.

Here are the steps I took.
01). I have a main form called COMPANIES. It is based on a query of the same name. I opened the form and I see the results of my query in the list box (LIST0). The list consists of three columns. Column 1 has the Company ID, Column 2 has the Company Name and Column 3 has the Company Address. Column 1 is bound so that value can be used by another query.

02). I created a form called LOCATIONS. It is based on a query of the same name. It uses the ID from the form COMPANIES and it displays the individual store locations for the select Company.

03). On the main form called COMPANIES, I used the tool wizard and added a subform that calls the form called LOCATIONS.

04). Now when I open the main form called COMPANIES I see the list of ID's and Company Names. the subform for LOCATIONS is empty.

05). In edit mode I go to the properties of LIST0. I find the OnDblClick.

During Testing
A) I have been able to add an event procedure that when the operator double clicks the Company ID the results of the query LOCATIONS appear on the screen. This is done my using the DoCMD.OpenQuery

B) I have been able to add an event procedure that when the operator double clicks the Company ID the results of the query LOCATIONS appear in the form called LOCATIONS. This is done using the DoCMD.OpenForm

Here is where I get lost, how to I get the results of the LOCATIONS form/query to appear on the same screen and the COMPANIES form/query
Mar 6 '07 #3
MSeda
159 Expert 100+
If I understand correctly you want the subform Locations to display the Locations Query result after a user double clicks on an item in a listbox, Right?

to do this in the list0_onDblclick() procedure you have already created you need to requery the locations subform. with a command Like
docmd.requery "LocationSub"

If you can't get this to work post the ondblclick code and we'll take a closer look
Mar 7 '07 #4
sesling
84
If I understand correctly you want the subform Locations to display the Locations Query result after a user double clicks on an item in a listbox, Right?

to do this in the list0_onDblclick() procedure you have already created you need to requery the locations subform. with a command Like
docmd.requery "LocationSub"

If you can't get this to work post the ondblclick code and we'll take a closer look
The Answer to your question is Yes. Below is the onDblClick code I am currently using. This one will display the results in a separate window versus on a subform on my main form.

Private Sub List0_DblClick(Cancel As Integer)
On Error GoTo Err_Command2_Click

Dim stDocName As String

stDocName = "LOCATIONS"
DoCmd.OpenForm stDocName, , acNormal, acEdit

Exit_Command2_Click:
Exit Sub

Err_Command2_Click:
MsgBox Err.DESCRIPTION
Resume Exit_Command2_Click

End Sub
Mar 7 '07 #5
MSeda
159 Expert 100+
Sorry to change directions on you, it was late when I replied to your post and I now see there is actually a much simpler solution to you situation.

1. Insert the Locations form onto your main form as a subform
2. Remove the criteria based on the listbox selection from the source query for LOCATIONS
3. Set the Link Master Fields and Link Child Fileds to COMPANY ID

One caveat: This will cause the location subform to update as soon as the user moves the selection to the Company rather than having to Double Click.

If you want the user to be required to double click then insert the subform but leave the link properties blank and leave the form criteria in your Query.
Expand|Select|Wrap|Line Numbers
  1. Private Sub List0_DblClick(Cancel As Integer)
  2. On Error GoTo Err_Command2_Click
  3.  
  4. Docmd.requery “LocationsSub” (or whaterver the name of the subform is)
  5.  
  6. Exit_Command2_Click:
  7. Exit Sub
  8.  
  9. Err_Command2_Click:
  10. MsgBox Err.DESCRIPTION
  11. Resume Exit_Command2_Click
  12.  
  13. End Sub
  14.  
Mar 8 '07 #6
sesling
84
Sorry to change directions on you, it was late when I replied to your post and I now see there is actually a much simpler solution to you situation.

1. Insert the Locations form onto your main form as a subform
2. Remove the criteria based on the listbox selection from the source query for LOCATIONS
3. Set the Link Master Fields and Link Child Fileds to COMPANY ID

One caveat: This will cause the location subform to update as soon as the user moves the selection to the Company rather than having to Double Click.

If you want the user to be required to double click then insert the subform but leave the link properties blank and leave the form criteria in your Query.
Expand|Select|Wrap|Line Numbers
  1. Private Sub List0_DblClick(Cancel As Integer)
  2. On Error GoTo Err_Command2_Click
  3.  
  4. Docmd.requery “LocationsSub” (or whaterver the name of the subform is)
  5.  
  6. Exit_Command2_Click:
  7. Exit Sub
  8.  
  9. Err_Command2_Click:
  10. MsgBox Err.DESCRIPTION
  11. Resume Exit_Command2_Click
  12.  
  13. End Sub
  14.  
That did the trick. Thx for all your help
Mar 13 '07 #7

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

Similar topics

4
by: Crystal | last post by:
Ok, I know this sounds weird, but it's really bugging me. I have a few list boxes on my form (basic pick a month, year, state stuff) and you can only choose one value. I need to be able to run a...
7
by: Rodney King | last post by:
Hi, I have developed an ASP page which dynamically displays a list of checkbox options based on a SQL statement. Here is my code: <div style="OVERFLOW:auto; Height: 150px"> <table> <% dim...
5
by: cmc_dermo | last post by:
I have a form that has a select list. A user chooses a value and the page refreshes showing the selected value in the dropdown box. So I want to use Javascript to get the selected query from...
19
by: James Fortune | last post by:
I have a lot of respect for David Fenton and Allen Browne, but I don't understand why people who know how to write code to completely replace a front end do not write something that will automate...
3
by: google | last post by:
I have a database with four table. In one of the tables, I use about five lookup fields to get populate their dropdown list. I have read that lookup fields are really bad and may cause problems...
10
by: Tom | last post by:
I am looking for some ideas for how to design the layout of the form for data entry and to display the data for the following situation: There are many sales associates. A sales associate can work...
0
by: ward | last post by:
Greetings. Ok, I admit it, I bit off a bit more than I can chew. I need to complete this "Generate Report" page for my employer and I'm a little over my head. I could use some additional...
17
by: freemann | last post by:
Can anyone provide example code showing how to send form results to a results page, email and a comma delimited file? Notice that I need it going to all three locations. Details: I have forms...
8
by: | last post by:
The problem lies here eval("document.TeeForm.amt.value(S+M)"); S and M suppose to add up and the total suppose to appear on the AMT field but it didn't. Any help? ...
9
by: MrHelpMe | last post by:
Hello again experts, I have successfully pulled data from an LDAP server and now what I want to do is drop the data into a database table. The following is my code that will insert the data but...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.