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

Pass value froma form to another

JustRun
127 100+
hi,

I have a problem with passing the value from a Form that "user should choose a start date and end date" to a Form that display the result in a Crystal Report Form

Actually it gives this error at runtime:
"SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM"

Expand|Select|Wrap|Line Numbers
  1. 'The form that dates will be picked from 
  2.  
  3. Public Class frmBuyDate
  4.     Public dateStart As String
  5.     Public dateEnd As String
  6.  
  7.     Private Sub btnShowReport_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnShowReport.Click
  8.         dateStart = dpStart.Value.ToShortDateString
  9.         dateEnd = dpEnd.Value.ToShortDateString
  10.         'MessageBox.Show(dateStart.ToString())
  11.         Dim objBuyRprt As New frmBuyRprt()
  12.         objBuyRprt.ShowDialog()
  13.     End Sub
  14. End Class
  15.  

Expand|Select|Wrap|Line Numbers
  1.  
  2. 'Here, both 'dateStart' and 'dateEnd' are Null !!!!!! This is the thing I want to know , WHY 
  3. I always used to do this with C# and it works, whats wrong here?
  4.  
  5. Public Class frmBuyRprt
  6.  
  7.     Private Sub frmBuyRprt_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  8.        Try
  9.             Me.BUYSTableAdapter.FillByDate(PHARMACYDBDataSet.BUYS, Convert.ToDateTime(frmBuyDate.dateStart), Convert.ToDateTime(frmBuyDate.dateEnd))
  10.  
  11.             Dim objBuyRprt As New CrystalReport1
  12.             objBuyRprt.SetDataSource(PHARMACYDBDataSet)
  13.             crvBuy.ReportSource = objBuyRprt
  14.         Catch ex As Exception
  15.             MessageBox.Show(ex.ToString())
  16.  
  17.         End Try
  18.  
  19.     End Sub
  20. End Class
  21.  

Expand|Select|Wrap|Line Numbers
  1. 'The Dataset Query'
  2.  
  3. SELECT  Med_ID, Med_Date, Med_Cat, Med_Name, Med_Qty, Med_Price, Med_TotalPrice
  4. FROM         BUYS
  5. WHERE     (D2 >= @startDate) AND (D2 <= @endDate)
  6. ORDER BY D2 DESC
  7.  
I tested the query and it works perfect, also the form of pickers works perfect.
Thanks.
Apr 27 '09 #1
1 1531
Enij
13
I'm not sure if I'm following this correctly, but...

On your second code example, line 8, you're trying to use frmBuyDate, but I can't see any code where this class has been instantiated:

Expand|Select|Wrap|Line Numbers
  1. Dim myBuyDate As New frmBuyDate
  2.  
  3. myBuyDate.ShowDialog()
  4.  
  5. ' test dialog result here
  6. If myBuyDate.DialogResult = DialogResult.OK Then
  7. ' use myBuyDate.dateEnd / etc here
  8. End If
  9.  
  10. ' >> dereference form dialog 
If no form has been instantiated, everything will be Nothing.

From the code provided, that's what it looks like to me anyway ;)
May 1 '09 #2

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

Similar topics

1
by: vishal | last post by:
hi i am using get method to pass data from one form to another and my value may contain & symbol. so when this is case the value after & sign is truncated which is logically true. so what...
4
by: Shufen | last post by:
Hi, I'm a newbie that just started to learn python, html and etc. I have some questions to ask and hope that someone can help me on. I'm trying to code a python script (with HTML) to get...
4
by: Fred | last post by:
Hi, i know how to pass a value from Javascript to ASP with a hidden field into a form and submitting it, or with cookies, but here i have to pass a lot of data in an array. There is a list of...
11
by: Vanessa | last post by:
Hi, I would like to know whether there's any way for me to pass an object by reference to another form? Regards Vanessa
3
by: Lyn | last post by:
Hi, I have been experiencing a problem passing a LIKE statement in the WHERE argument of a DoCmd.Openform statement. I have posted that issue separately. However, in an attempt to work around...
4
by: tom | last post by:
Hi Experts, I want to pass the selectedDate value from my calender form to another web form or a web user control. Could you please show me how to do this? Thanks in advance.
2
by: c676228 | last post by:
Hi, This is my first time to post asp.net question on this forum. I have a question for "How to pass the first form value to the next form" I have enrollinfo.aspx form which look like as follow:...
17
by: Rabbit | last post by:
Hi, On my 1st page, i have a function which gets a new ID value and need to transfer to another immediately. which I want to get in 2nd page using Request.form("txtID"), but doesn't work, the...
12
by: raylopez99 | last post by:
Keywords: scope resolution, passing classes between parent and child forms, parameter constructor method, normal constructor, default constructor, forward reference, sharing classes between forms....
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
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.