2 Replies - 12848 Views - Last Post: 17 November 2006 - 08:09 PM Rate Topic: -----

#1 Big T  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 9
  • Joined: 13-November 06

Passing a value from a form to a VB DataReport

Posted 13 November 2006 - 05:06 PM

Is it possible to pass a value from a form to a DataReport?

I'm using VB6, and would like to take the contents of text box txtInvoiceNumber and pass that value to a data report, thus generating an invoice based on the invoice number on the screen. I don't see any obvious means of doing this.

Coming from a MS ACCESS background, I can set up an SQL statement like :

 SELECT * FROM INVOICES WHERE INVOICENUMBER = [FORMS!INVOICES!txtInvoiceNumber] 


and run a report based on that query.

I'm not really looking for a chunk of code per se, inasmuch as I'm looking for the general syntax as to how to pass the value from a form to the report. Please let me know if I'm mising any vital info, I'll be more than happy to post it (forgive me, I'm a newbie here...LOL)

Thanks - T

This post has been edited by Big T: 13 November 2006 - 05:26 PM


Is This A Good Question/Topic? 0
  • +

Replies To: Passing a value from a form to a VB DataReport

#2 2much2young  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 14
  • Joined: 16-November 06

Re: Passing a value from a form to a VB DataReport

Posted 16 November 2006 - 12:50 AM

View PostBig T, on 13 Nov, 2006 - 05:06 PM, said:

Is it possible to pass a value from a form to a DataReport?

I'm using VB6, and would like to take the contents of text box txtInvoiceNumber and pass that value to a data report, thus generating an invoice based on the invoice number on the screen. I don't see any obvious means of doing this.

Coming from a MS ACCESS background, I can set up an SQL statement like :

 SELECT * FROM INVOICES WHERE INVOICENUMBER = [FORMS!INVOICES!txtInvoiceNumber] 


and run a report based on that query.

I'm not really looking for a chunk of code per se, inasmuch as I'm looking for the general syntax as to how to pass the value from a form to the report. Please let me know if I'm mising any vital info, I'll be more than happy to post it (forgive me, I'm a newbie here...LOL)

Thanks - T




you can try something like this

rptMyReport.Sections("PageHeader").Controls("lblInvoiceNo").Caption = txtInvoiceNumber.text

rptMyReport.show


Was This Post Helpful? 1
  • +
  • -

#3 Big T  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 9
  • Joined: 13-November 06

Re: Passing a value from a form to a VB DataReport

Posted 17 November 2006 - 08:09 PM

View Post2much2young, on 16 Nov, 2006 - 12:50 AM, said:

View PostBig T, on 13 Nov, 2006 - 05:06 PM, said:

Is it possible to pass a value from a form to a DataReport?

I'm using VB6, and would like to take the contents of text box txtInvoiceNumber and pass that value to a data report, thus generating an invoice based on the invoice number on the screen. I don't see any obvious means of doing this.

Coming from a MS ACCESS background, I can set up an SQL statement like :

 SELECT * FROM INVOICES WHERE INVOICENUMBER = [FORMS!INVOICES!txtInvoiceNumber] 


and run a report based on that query.

I'm not really looking for a chunk of code per se, inasmuch as I'm looking for the general syntax as to how to pass the value from a form to the report. Please let me know if I'm mising any vital info, I'll be more than happy to post it (forgive me, I'm a newbie here...LOL)

Thanks - T




you can try something like this

rptMyReport.Sections("PageHeader").Controls("lblInvoiceNo").Caption = txtInvoiceNumber.text

rptMyReport.show



Here's what I'm working with:


' This routine runs if an invoice number has not yet been assigned:

	MyConn.Provider = "Microsoft.Jet.OLEDB.4.0"
	MyConn.Open ("C:\database\kayes.mdb")
	MyRs.ActiveConnection = MyConn
	MyRs.CursorLocation = adUseClient

' *** Assign next invoice number ***

	MyRs.Open "INSERT INTO InvoiceGenerator (TAKEN) Values ('Yes')"  
	  
' *** The InvoiceGenerator table holds 2 values: an Automatically assigned invoice number and a boolean field  representing whether the invoice number has been assigned yet. ***   

	MyRs.Open "SELECT * FROM INVOICEGENERATOR" 

' *** Open InvoiceGenerator table, pass latest invoice number to lblInvoiceNumber ***

		MyRs.MoveLast
		lblInvoiceNumber.Caption = MyRs("InvoiceNumber")

	MyConn.Close




What I'm trying to do, with some sort of SQL statement I suppose, is pass the value that was assigned to lblInvoiceNumber to the datareport; which in turn fetches only the data affiliated to that particular invoice number from the database to the data report.

I think I see what you had in mind, 2much2young, and it seems my question wasn't quite clear enough.

Any ideas from here perchance?

Thanks!

T
Was This Post Helpful? 1

Page 1 of 1