473,396 Members | 1,895 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,396 software developers and data experts.

How to create a form with parameters? (Using VB Microsoft Access)

I basically need a form like this:

Start date: _____
End Date: _______
Trigger: ________

Whereby the start date, end date and trigger are the parameters to be keyed in by the end user before the report is to be generated (only for those particular dates and trigger value)

So far this is my code in creating the form. Unfortunately it's wrong.

WRONG code for form:::
Expand|Select|Wrap|Line Numbers
  1. Private Sub Command2_Click()
  2.     QueryDate = [Forms]![Bond Price Exception 1]![start_date As Date]
  3.     QueryDate = [Forms]![Bond Price Exception 1]![end_date As Date]
  4.     PctChange = [Forms]![Bond Proce Exception 1]![trigger As Single]
  5.  
  6.     Call BondPriceException([start_date As Date], [end_date As Date], [trigger As Single])
  7. End Sub
This is my VB code for the module:::

Expand|Select|Wrap|Line Numbers
  1. Sub BondPriceException()
  2. On Error Resume Next
  3.     Dim sqltext As String
  4.     Dim start_date As Date
  5.     Dim end_date As Date
  6.     Dim trigger As Single
  7.  
  8.     start_date = "9/17/2010"
  9.     end_date = "9/24/2010"
  10.     trigger = "0.02"
  11.  
  12.     sqltext = "SELECT DISTINCT [Bond Price].Date, [Bond Price].Instrument, [Bond Price].[MTM Price], [Bond Price].[Current Rate] INTO TempException1 " & _
  13.                 "FROM [Bond Price] WHERE [Bond Price].Date=#" & start_date & "#"
  14.     DoCmd.RunSQL sqltext
  15.  
  16.     sqltext = "SELECT DISTINCT [Bond Price].Date, [Bond Price].Instrument, [Bond Price].[MTM Price], [Bond Price].[Current Rate] INTO TempException2 " & _
  17.                 "FROM [Bond Price] WHERE [Bond Price].Date=#" & end_date & "#"
  18.     DoCmd.RunSQL sqltext
  19.  
  20.     sqltext = "SELECT tp.Date, tp.Instrument, tp.[Current Price], tp.[Previous Price], b.Typology, bt.[Trade ID], bt.[Trade Date], bt.[Deal Price], bt.Portfolio, btn.[Nominal Quantity] " & _
  21.                 "INTO ExceptionRpt FROM " & _
  22.                 "(((SELECT t2.Date, t1.Instrument, t1.[MTM Price] AS [Current Price], t2.[MTM Price] AS [Previous Price] FROM TempException2 t2 " & _
  23.                 "INNER JOIN TempException1 t1 ON (ABS(t1.[MTM Price]/t2.[MTM Price]-1)>" & trigger & ") AND (t2.Instrument=t1.Instrument)) tp " & _
  24.                 "INNER JOIN [Bond] b ON b.Instrument = tp.Instrument) " & _
  25.                 "INNER JOIN [Bond Trade] bt ON bt.Instrument = b.Instrument) " & _
  26.                 "INNER JOIN [Bond Trade Nominal] btn ON btn.Reference = bt.Reference AND btn.Date = tp.Date "
  27.     DoCmd.RunSQL sqltext
  28.  
  29.     sqltext = "drop table TempException1"
  30.     DoCmd.RunSQL sqltext
  31.  
  32.     sqltext = "drop table TempException2"
  33.     DoCmd.RunSQL sqltext
  34. End Sub
Oct 20 '10 #1
3 1593
Delerna
1,134 Expert 1GB
it should be more like this I think
Expand|Select|Wrap|Line Numbers
  1. Private Sub Command2_Click()
  2.    dim StartDate  As Date,EndDate  As Date,PctChange As Single
  3.    StartDate = [Forms]![Bond Price Exception 1].[start_date]
  4.    EndDate  = [Forms]![Bond Price Exception 1].[end_date]
  5.    PctChange = [Forms]![Bond Proce Exception 1].[trigger]
  6.  
  7.    Call BondPriceException(StartDate, EndDate,PctChange)
  8. End Sub
  9.  
Oct 20 '10 #2
thanks but when i clicked run nothing happened.
Oct 20 '10 #3
NeoPa
32,556 Expert Mod 16PB
That may well be, but the problem you asked about nevertheless has that fix.

If your other code doesn't work then that's maybe something you need to ask for help with separately. As far as this question goes, about tying in the parameters from the form, Delerna's response is perfect and works.
Oct 20 '10 #4

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

Similar topics

3
by: Victoria Holowchak | last post by:
I was hoping that Microsoft Access 2002 would allow users to see all the columns of an Oracle database table that contained more than 255 columns. I noticed that my Oracle8 ODBC driver is only at...
5
by: Hannie | last post by:
I am currently doing my project using VB.NET I have a database which contains all my data that the user key in. The problem is, when i click the retrieve button on the form, the details that the...
2
by: Vincent | last post by:
I have been given the task of creating a scheduler for a POS program my company sells. They are currently using the Microsoft FlexGrid as the crux of the design. However, I want to be able to...
1
by: dhussong | last post by:
I am attempting to use Visual Studio 2005 (Visual Basic) and the Enterprise Library 2.0 Data Access Application Block with a Microsoft Access database. I know the names of my Access databases but I...
1
by: glenn | last post by:
Hi folks, Have read a bit on this topic but so far no positive results. I have the following table named 'discussions': id discussionNumber from to status 1 1 ...
23
by: Steven TK | last post by:
Hi everyone, I wonder who can help me on the filter the Start Date and End Date. I still cannot manage to filter it. Eg. When the user click the StartDate(comboBox as 16/7/07), the Start...
1
by: huntress | last post by:
I am trying to create pivot tables using VBA in Access 2003. Is this possible? How do I go about it?
1
by: BharathP | last post by:
Hi, I need to transfer data of one of the table in DB2 to Microsoft Access. I tried using DBOP data source using Configuration assistant in DB2 and SQL passthrough in Microsoft Access. I think I'm...
1
by: BharathP | last post by:
Hi, I need to transfer data of one of the table in DB2 to Microsoft Access. I tried using DBOP data source using Configuration assistant in DB2 and SQL passthrough in Microsoft Access. I think I'm...
7
by: Ken Jones | last post by:
Can this conversion be done using Microsoft Access? If so how? Could this be done using TRANSFORM and PIVOT SQL statements? The Old Format columns are NO and URL The New Format...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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,...
0
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...
0
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...

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.