473,602 Members | 2,764 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Search form to display results in results form: can't invoke sql

Hi:

I have an Access 97 Search form set up - a couple of combo boxes, a
couple of text fields and a command button. I want the command button
to run an SQL script and then open the results form. I can get the
button to open the other form but I can't get it to run the module
with the subroutine in it. This is my first sorti into programming
Access so be kind - I have some SQL and ASP experience but these
modules are a problem for me.

Thanks,

Jules
Nov 12 '05 #1
6 2307
Jules wrote:
Hi:

I have an Access 97 Search form set up - a couple of combo boxes, a
couple of text fields and a command button. I want the command button
to run an SQL script and then open the results form. I can get the
button to open the other form but I can't get it to run the module
with the subroutine in it. This is my first sorti into programming
Access so be kind - I have some SQL and ASP experience but these
modules are a problem for me.


Modules are just documents for your functions and procedures. You don't
run them. Just call the function/sub by its name.

--
Bas Cost Budde
http://www.heuveltop.nl/BasCB

Nov 12 '05 #2
Seems unlikely that you'd need to "run an SQL script" and _then_ open
another Form -- the much more common structure would be to construct the SQL
query for the search then replace the RecordSource of the results form with
that SQL.

You don't "run modules" -- you call Procedures, either Sub (which do not
return a value) or Function (which do return a value) ... but, in the
situation you describe, it would be much more likely that you'd want to put
your code in the Click event of the Command Button. Procedures exist in
modules, but are executed directly, with no reference to the module

For a Sub named YourSub with arguments A1, A2, and A3, the statement would
be:

YourSub A1,A2,A3

For a Function named MyFunc with the same arguments,

MyVariable = MyFunc(A1,A2,A3 )

Investing a little time with a self-study about Access might be a good idea.
For the raw novice, _Microsoft Access <versionnumbe r> Step by Step_
published by Microsoft Press. Some other books that begin at the beginning
and go deeper are _Special Edition - Using Microsoft Access_ by Roger
Jennings, published by Que and _Microsoft Access Inside Out" by John L.
Viescas, published by Microsoft Press.

For the power user moving to developer level, _Programming Microsoft Access
2000_ or _Programming Microsoft Access 2002_, by Rick Dobson, published by
Microsoft Press. There is a 2003 edition that I haven't seen, but I would
guess that it would be good, too.

The consensus choice for a detailed, in-depth reference for developers is
_Access <versionnumbe r> Developer's Handbook_ by Litwin, Getz, et al,
published by Sybex.

For information on other resources available to help, visit the Resources
section of http://ntaccess.tripod .com.You'll find other's views and
recommendations in the FAQ at http://www.mvps.org/access and in the archives
of this newsgroup at http://groups.google.com.

Larry Linson
Microsoft Access MVP

"Jules" <ju************ *@ndm.gov.on.ca > wrote in message
news:f5******** *************** ***@posting.goo gle.com...
Hi:

I have an Access 97 Search form set up - a couple of combo boxes, a
couple of text fields and a command button. I want the command button
to run an SQL script and then open the results form. I can get the
button to open the other form but I can't get it to run the module
with the subroutine in it. This is my first sorti into programming
Access so be kind - I have some SQL and ASP experience but these
modules are a problem for me.

Thanks,

Jules

Nov 12 '05 #3
Bas Cost Budde wrote:
Modules are just documents for your functions and procedures. You don't
run them. Just call the function/sub by its name.


Hmmm, thought I tried that - probably wrongly then. OK, this is what I
did. In Properties for the command button, I selected OnClick and went
into the Code builder and it popped up with a default code. I then
tried to modify the DoCmd to something that will invoke the subroutine
but I find nothing related to functions or subroutine, I tried to
OpenModule but it opened it in editing format so I could see the code.

I can't just set RowSource to the SQL code because I have to do some
manipulations first. The RowSource is actually a temporary table so I
have to perform the search (using SQL) then dump the recordset to the
temporary table.

Any other ideas?
Nov 12 '05 #4
Got it now.

Call subroutine
DoCmd.OpenForm "formname"

Works perfectly,

Jules
Nov 12 '05 #5
Jules wrote:
Got it now.

Call subroutine
DoCmd.OpenForm "formname"

Works perfectly,

Jules


Great.

Call is optional; but if you omit it, you must also get rid of the
parentheses around your parameters. Like

Call yourSub(par1)

becomes

yourSub par1

--
Bas Cost Budde
http://www.heuveltop.nl/BasCB

Nov 12 '05 #6
ju************* @ndm.gov.on.ca (Jules) wrote in message news:<f5******* *************** ****@posting.go ogle.com>...
Got it now.

Call subroutine
DoCmd.OpenForm "formname"

Works perfectly,

Jules


Ok, I have decided to modify the form and have the results display in
a listbox below the criteria fields. Before I do this, I just want you
to know that when I select criteria then click on the "Search
Publications" command button, the query is run, the recordset is
dumped into a temporary table and then the DoCmd.OpenForm opens the
Found_Publicati ons form with the results properly displayed in the
list control. Now, I want to combine the two forms into a top area
where the criteria are set and the bottom area where the results are
displayed. I have used:

Call PerformSearch
DoCmd.GoToContr ol "listSearchResu lts"

and then the event property for the OnFocus event for
listSearchResul ts is (currently)

DoCmd.Beep

and it beeps which means that the focus has been transferred but I
don't know how to refresh the display of the new results in the lower
list box. The results table is filled with the correct results but the
list box, which is properly tied to the results table, is not
refreshing the display of the table when the criteria change.

Help please,

Jules
Nov 12 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
3522
by: CharitiesOnline | last post by:
Hello, I have set this script up to add paging to a search results page. Which on the first page works fine. I calculates how many pages there should be depending on the number of results returned from my search and how many records I have set it to display per page. All great so far, HOWEVER..... When you click the next link to see the next 10 results on the next page, it just dumps the search details and pulls up all the records in the...
1
2094
by: N. Graves | last post by:
Hi, I want to have a Search Dialog box that has several text box and fields to build a search and display the results in a form. I can do everything that I need to if I us a report but I would like to have the search from data displayed in a form. The structure that I have for this was take from the Asset Manger from MS. Anyway I open a report that in turn opens up a search form that allow me to select data. Then you continue by...
4
3477
by: Dica | last post by:
i apologize for what is no doubt a very rudimentary question, but i'm still trying to wrap my brain around .net coding habits. in classic asp, if i wanted to show search results, i'd just post the form data over to another page or call a showSearchResults sub on the search page. in .net, i can't post to another page, so i need to show the search results on the same page as the search form page. i could write a sub in my code behind that...
1
1139
by: Chris Newman | last post by:
i am developing a web based database using PHP and mySQL. Want the search interface to display a message "No results found" if search unsuccessful . Here's how I was proposing to accomplish this. Two PHP scripts (A) A search interface mainly html with embedded PHP block that displays a
4
2112
by: zakhirn | last post by:
Hello, I have an extremely new user to XML and XSL, and I would like to know how to search XML data via a input form in HTML, and have the results displayed in HTML. If anyone has code that can do that, could you please post the relevant files. I have searched the internet for a while now, and have been completely unsuccessful. I would like to do it using javascript in my XSL file if possible, or using CGI script to search the XML...
1
3453
by: grabit | last post by:
Hi Peoples i have a search page with a form field "subject" on my results page i have a paging routine . the first page lists its 10 records no trouble but when i click the "next" link i get a error telling me "subject is not defined in form" How can i overcome this please. I will post the page down to the end of the paging routine coz its not very long anyway. <cfquery name="searchResults" datasource="#dsn#"> SELECT threadID, posttype,...
22
3065
by: Zytan | last post by:
I have public methods in a form. The main form calls them, to update that form's display. This form is like a real-time view of data that is changing. But, the form may not exist (it is created / destroyed at user request). I can check form != null to prevent incorrect access. But, the form could disappear immediately after the check, before the method is run. Or someone could click 'close' when it's in the middle of an update. ...
1
7523
Merlin1857
by: Merlin1857 | last post by:
How to search multiple fields using ASP A major issue for me when I first started writing in VB Script was constructing the ability to search a table using multiple field input from a form and having the sql statement dynamically built according to the input provided by the user. I have used the method described here hundreds of times it is quick and adaptive. I generally use a frames page for the search, in this way the search is maintained...
0
7993
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
7920
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8404
jinu1996
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8054
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8268
tracyyun
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5440
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3900
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2418
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
1254
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.