473,326 Members | 2,099 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,326 software developers and data experts.

On click run SQL query on a subform

i've made a query as a form and an action button to run the a query.I want to click the button, it the result of the query should be populated on a subform.

i tried :

Expand|Select|Wrap|Line Numbers
  1. Me.SubFrmChild.SourceObject = "Query." & "select id from table1"
Expand|Select|Wrap|Line Numbers
  1. 'Forms![Frm_Test]![SubFrmChild].Form.RecordSource*=*"select id from table1"
its not working. please help
Oct 23 '18 #1
1 3510
twinnyfo
3,653 Expert Mod 2GB
mdikbal99,

Welcome to Bytes!

I think I understand what you are trying to do, but your terminology prevents me from being certain about it.

First, a query cannot be made as a form. A query simply extracts data from a database. A form displays that information in a user interface. But, I think I understand what you mean.

Second, in order for you to have a subform on a form, the best way to do that is to create that subform, and place it on your main form. Then you can assign a query as a record source for that subform. However, you much make sure that when you create the subform that all the appropriate controls havecontrol sources that match up with the results of your query. In your case, you need a subform that has a control for "ID".

To assign a query as a record source:

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdAssignQuery_Click()
  2.     Dim strSQL As String
  3.  
  4.     strSQL = "SELECT ID FROM Table1;"
  5.     With Me.fsubYourSubForm
  6.         .RecordSource = strSQL
  7.         .Requery
  8.     End With
  9.  
  10. end Sub
However, I would guess that you have more going on that what is on the surface.

Without greater detail, we cannot assist much beyond this.

Hope this hepps!
Oct 24 '18 #2

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

Similar topics

1
by: Argus Rogue | last post by:
Hello All Access Guru's: I was wondering if you could assist me with a little problem that I am having using subform. Is it possible to scroll down a subform to a particular record, click on...
1
by: Stephen D Cook | last post by:
I have a form with txtSN text box, btnShow button, and a subform. The form is bound to a Table. The button is bound to a lookup query. The query is bound to the text box. I want to be able to...
0
by: Stephen D Cook | last post by:
I have a form linked to a table. In the form I have a textbox, a command button, and a query subform. I dragged the query onto the form to create the query subform. The query has a field named...
1
by: Parasyke | last post by:
I have a mainform named "SearchByManufacturer" that has a subform (in DataView form) named "Products Query Subform" which get its data from a query called "Products Query" based on a table called...
13
by: MLH | last post by:
I have a form, frmVehicleEntryForm. On it is a subform control named frmAddnlOwnrListSubForm. The subform control's source object is frmAddnlOwnrListSubForm. When I click on the subform control,...
3
by: 2myle | last post by:
Hello experts, Sorry, this is probably a newbie-question... I have a form for customer details, which includes a subform (datasheet, multiple columns) that lists the orders that correspond to...
3
by: dstork | last post by:
Has anyone else experienced Access 2007 crashing when users right click on the subform (with the intention to use the copy feature in the shortcut menu). I went through Allen Browne's...
2
by: dbdb | last post by:
Hai, need a help please. i have a form to view the query subform 1. form name : form1 2. query subform name : subform1 3. textbox name : txtclass1 4. command button name : cmd1 i want to...
13
by: darnnnel | last post by:
Hi this is what i have so far, but it doesnt seem to be working right. I am getting an error here: qryReferral.Status = 'Open' Private Sub cmdFltrOpen_Click() Dim sSQL As String ...
3
by: ThingTwo | last post by:
I'm a relative newbie to Access, working in 2003 and trying to build a very simple client database for my company. Here's the basic set-up I have so far: -Clients Table contains all the relevant...
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: 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...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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.