A form printing problem

Hi,
  I use VB6 + ACCESS and I have some data in the access database.  I would like to print a particular record in tehe database.  I am now using VB6 datareport.  However, it prints all the record!! How can I print a particular record?? Any input requires??

Thanks
Gorexy
gorexyAsked:
Who is Participating?
 
rovermConnect With a Mentor Commented:
don't use brackets!
Further, if you build your sql using the SQL Builder, declaring a condition for a field with '=?' then SQL Builder says something like 'Parameter....'.
Then go to the properties of your command, click the tab 'Parameters' and set all the properties.
0
 
rovermCommented:
Place a filter on the database or use a DataEnvironment to build a SQL Statement
grtx, RoverM
0
 
gorexyAuthor Commented:
sorry to reject first
i am new to use dataenvironment and datareport
can u give me an example?
what is grtx and RoverM?
thanks
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
rovermCommented:
grtx = greetings
RoverM is my name !

Okay, make sure to have a connection in your DE (dataenv.).
Add a command to it
Click 'SQL Statement' and type (something like):
SELECT * FROM TABLE
WHERE KEYVALUE = SEARCHVALUE

in this example:
* means: return all field values
KEYVALUE = field in database to reconize which record to fetch
SEARCHVALUE = value which KEYVALUE must equal to.

If you want SEARCHVALUE to be variable then replace it with '?' (without the quotes).
Then you must run the command before accessing the DR with a value for the PARAMETER (see MSDN OnLine).

Easier way:
Click 'SQL Builder' instead of 'SQL Statement' and drag and drop the nessecary table(s) from the DataView window. The SQL statement is automaticly build.

0
 
gorexyAuthor Commented:
sorry I can't fully understand how can I set the variable in SEARCHVALUE.  I use ? but it said errors.
Pls advise

Gorexy
0
 
rovermCommented:
assuming:
deDB is your dataenvironment,
comSQL is your SQL command,
strVal is the parameter value
rsResult is a recordset

fire the sql query by:

deDB.Open
rsResult = deDB.comSQL(strVal)

The data will be in rsResult, based on your parameter.
You can also use:

deDB.Open
deDB.comSQL(strVal)

then invoke the datareport, which dataset is set to deDB and the command to comSQL!

0
 
gorexyAuthor Commented:
I can't use deDB.Open ??
0
 
gorexyAuthor Commented:
would u mind I send u my code?
0
 
gorexyAuthor Commented:
I use
dataenvironment1.connection.open
dataenvironment1.command1(input)
datareport1.show

But the second line has problem
how can I pass the parameter "input" into the dataenvironment??
Also, how can I set the variable in dataenvironment??
0
 
gorexyAuthor Commented:
I use
dataenvironment1.connection.open
dataenvironment1.command1(input)
datareport1.show

But the second line has problem
how can I pass the parameter "input" into the dataenvironment??
Also, how can I set the variable in dataenvironment??
0
 
gorexyAuthor Commented:
Oh finaly I can print it out!
Thanks :>
0
 
rovermCommented:
Welcome!
0
All Courses

From novice to tech pro — start learning today.