473,796 Members | 2,480 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to Test Function in Immediate Window

I am trying my first functions in my code. I have a set of queries
that runs to create temp tables with the right data for some reports.
They can run for a long time, so I want the user to know what is in the
tables (date parameters) before running all the queries. This way, if
the data in the tables is not for the time period the user needs for
reporting, s/he knows to recreate the data.

I just want to find the data in the tables and display it to the user -
probably will do a YES/NO to continue or not.

So, I wrote the following function, and I want to test it in the
immediate window (without running the whole process from the form). I
just can't figure it out. I don't understand the use of "passing
parameters" - when you call the function (which I'll have to do from my
code as well) what do I "pass" to the function and what does that look
like?

I also want to find the MAX Salesdate on the tmptblMTDSales. Can I do
this in DLOOKUP too?

Hope someone can help - it's very confusing to me and Help doesn't
explain for me.

Thanks

Code:
Function GetMoQtrYear(Mo EndDate As Date)
' Find the dates on the Temp Tables. If they are not right, tell the
user to rerun
' Merch Pct incr/decr to put the right data in the tables used in the
dashboard reports

Dim FiscalMonth As Integer ' Fiscal Month on MTD Table
Dim FiscalMYear As Integer ' Fiscal Year on MTD Table
Dim WEDate As Date ' Max Week End date on MTD Table
Dim FiscalQYear As Integer ' Fiscal Year on QTD Table
Dim FiscalQuarter As Integer ' Fiscal Quarter on QTD Table
Dim FiscalYYear As Integer ' Fiscal Year on YTD Table

' Get the Fiscal Month, Year and Last (max) week end date on MTD to
see if it's the
' right data for the week end requested to process
FiscalMonth = DLookup("[FiscalMonthNum]", "tmptblMTDSales Data", _
"[WeekEndDate]= Forms![frmPrintReports]!GetWkMoDate")
FiscalMYear = DLookup("[FiscalYearNum]", "tmptblMTDSales Data", _
"[WeekEndDate]= Forms![frmPrintReports]!GetWkMoDate")
' How to get MAX week end date?
' WEDate = DLookup("[WeekEndDate]", "tmptblMTDSales Data", _
' "[WeekEndDate]= Forms![frmPrintReports]!GetWkMoDate")

' Get the Quarter and Year on the Qtr Table (Max sales date needed
too?)
FiscalQYear = DLookup("[FiscalYearNum]", "tmptblQTDSales Data", _
"[SalesDate]= Forms![frmPrintReports]!GetWkMoDate")
FiscalQuarter = DLookup("[FiscalQtrNum]", "tmptblQTDSales Data", _
"[SalesDate]= Forms![frmPrintReports]!GetWkMoDate")

' Get the Fiscal Year on the Year table (Max sales date needed too?)
FiscalYear = DLookup("[FiscalYearNum]", "tmptblYTDSales Data", _
"[SalesDate]= Forms![frmPrintReports]!GetWkMoDate")

' Show all dates to the user. If not right, stop the code so they can
run the data gathering
MsgBox "Fiscal Month and Year on MTD Table is " & FiscalMonth & " "
& FiscalMYear _
& "Fiscal Quarter and Year on QTD Table is " & FiscalQuarter &
" " & FiscalQYear _
& "Fiscal Year on YTD Table is " & FiscalYear _
& "If any of these is NOT right, rerun Merch Pct to create
Table Data"

End Function

Dec 15 '05
11 18307
Jana -
( and to Lyle, too - your comments kept my energy for this up!)

I'm liking this a lot!!!

I've gotten everything to work - thank you SO very much - but I'm not
done. I:

1* Learned what vbCrLF was - am happily using that.
Basically, I figured that one out myself, but now wanted to see if
there were other "useful" literals, and can't find anything on this in
Help or my several books. Are there others? Is there a place I can
look?

2* Started to put in error handling, and decided to post first, since
this is working. But I wanted you to know that I plan to reorganize
the whole print code to make sure all Dimensions are at the top and
that I am being more consistent with the names of variables. I
'discovered' that if I dim the variable at the top, once, I can use it
in the entire module! Basic, I'm sure, but I guess I didn't ever
really 'get' that. And I'm making sure every sub has error handling,
and that I'm using CASE where I can, rather than tedious IF THEN ELSE
statments for a simple check of a value. Have to figure out what
errors to trap; luckily for me I haven't experienced any yet in my
testing. (Poor testing, that!) Fortunately, we are not in the office
on Monday, so I can spend the day cleaning up all this code.

3* I put in the Min and Max code for Year; it's great. Wasn't sure if
it was really necessary for the user, but it WAS necessary for me to be
sure I really learned all this, so the user gets it! (That's the
privilege I have for being the only 'programmer' in this company) This
is how I learn best - following an example that is real-life, and my
life.

4* It probably took me the longest time to really understand the
setting the function to true when there was a problem. Until I worded
the situation as I just did here, it seemed inverted - 'False' is 'bad'
- so the result should be 'False'. I've got it now!

5* I am also finding other places to use functions. The big thing
here is that I'm not so afraid of them anymore - that's REALLY big for
me.

Again, thanks for bearing with me. I can't find the right words to
express my delight in the success my fingers have had here - or the
gratitude for your time, effort and patience. I don't know if you
needed all this detail, but after all the time you spent on my behalf,
I wanted you to know what I really did with and for your efforts.

Happy New Year.
Until next time -
sara

Dec 22 '05 #11
Sara:

Right now, at this very moment, I am doing a touchdown dance just for
you! :)
1* Learned what vbCrLF was - am happily using that. --You can find information on other constants in VB by searching for
'Visual Basic Constants' in Help.
2* I 'discovered' that if I dim the variable at the top, once, I can use it
in the entire module! Basic, I'm sure, but I guess I didn't ever
really 'get' that. --For more explanation of when/where to Dim a variable, search for
Scope in Help. In addition to module level variables, there are global
variables you can define that will work across different modules.
Global variables can be handy when properly used, but can be a
nightmare to track when debugging. Use them carefully and only when
you really need them, and you'll be fine.
4* It probably took me the longest time to really understand the setting the function to true when there was a problem.
--Easier to understand if you think of the function answering the
question "Do I need to rebuild the data?"
5* I am also finding other places to use functions. --Yay! I knew that once you wrapped your brain around how to use them,
you'd see applications for them everywhere :)
Again, thanks for bearing with me.

--You are quite welcome!!!! I am so very glad I could help you out. I
am a firm believer in the Karma Credit Plan. Since I have found so
many answers in this group, I think it's only fair to try and help
others out when I can. Guess that's what makes a group work!

Have a wonderful holiday season,
Jana

Dec 22 '05 #12

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

Similar topics

3
3437
by: Russell Stevens | last post by:
Can anyone tell me how to get to the immediate window in VS2005. The help file says (when debugging) to click Debug, Windows, Immediate. There is no Immediate window listed there, nor anywhere else I can find it. Also, is there a trick now to single step. I can't find that anywhere either. Thanks Russ Stevens
1
1336
by: DougS | last post by:
When I'm debugging an ASP 2.0 application and I'm trying to use the immediate window to interrogate some classes I cant reference anything in my code. When I type ?dvClient.Rows.Count it gives me no intellisense and it says object not found. I also have VS 2003 installed on this machine. What am I doing wrong? Thanks, DougS
5
5646
by: vul | last post by:
In VB6 I used to use Immediate Window to get or change values of variables. It is very convenient while debugging. I used drag and drop operation to paste the variable name into Immediate Window. In VB 2005 this approach either doesn't work or I need to do it some different way. Of course VB 2005 environment allows to see values right in the code window, but it's true only for not too long strings. With a long string I still need Immediate...
2
2597
by: dgk | last post by:
Using VS2005 Standard Edtion, I have an Immediate window during ASP debugging. My co-worker, using VS2005 Team Edtion does not have an Immediate window. He does have a Command window, which is sort of ok but doesn't have intellisense. Documentation shows that editions above Express do have immediate windows. We've looked under Debug, View, and just about everywhere else. I don't see the Immediate window under View on my system either,...
3
2309
by: Photobug | last post by:
I have downloaded Allen Browne's function TableInfo() and am getting a ByRef Type Mismatch error when I try to execute it. I don't know if it is a reference problem or not, but my references for Access 2000 are set at: VB for Applications MS Access 9.0 Object Library OLE Automation MS ActiveX DataObjects 2.5 Library MS VB for Apps Extensibility 5.3
6
2842
by: Frank Rizzo | last post by:
I am using the Immediate Window a lot to see the progress of the application. In VS2003, if your cursor was at the very bottom, the window would scroll down whenever something new showed up. If your cursor was somewhere in the middle of the text output, then there would be no scrolling. In VS2005, the Immediate Window scrolls regardless of where the cursor is which is very annoying. Sometimes you want to go back up in the window to...
4
3092
by: Armin Zingler | last post by:
Hi, I feel fooled.. In the immediate window, if I enter ? DateTime.Now.Kind I get "Unspecified {0}". The result - I expected "local" - lead to some time consuming deliberations. Today, I execute MsgBox(DateTime.Now.Kind)
4
2119
by: mgfine | last post by:
We're new to using VB 9 and we cannot invoke an immediate command window from an immediate window. Typing >cmd in the immediate window does bring up a command window but we're looking for the immediate command window that we used in VB 7. Thanks.
0
2251
by: mgfine | last post by:
This question was first posted in the VB forum: We're new to using VB 9 (Visual Studio.Net 2007) and we cannot invoke an immediate command window from an immediate window. Typing >cmd in the immediate window does bring up a command window but we're looking for the immediate command window that we have used in VB 7. Thanks.
0
9680
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
10456
Oralloy
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10230
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
7548
isladogs
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6788
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
5442
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
4118
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
2
3731
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2926
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.