DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 6 of 6

Thread: printing a single current record

  1. #1
    Join Date
    Aug 2004
    Posts
    43,023

    printing a single current record

    [Originally posted by Rich Thomas]

    I have created a form that I can enter my data into. It stores the information, ok. The problem is that I have made a form to print my data on. I can't get my printform to retreive the current record in my database that I have open. I have tried to link/select/and other ways to get it to work. I have tried using reports. But I can not import pictures due to a bug in VB6. And VB Report or Crystal Reports prints every record in the database. Please give me some Ideas????????

  2. #2
    Join Date
    Aug 2004
    Posts
    43,023

    Re:printing a single current record

    [Originally posted by gonzalo]

    did you tried by printing the form?

    try this

    private sub CommandPrint_click()
    yourform.print
    end sub

    note: the print command will print using the default printer, and only will print the form, not the screen

    other thing is, you have to change the units to pixelles

    see ya

  3. #3
    Join Date
    Aug 2004
    Posts
    43,023

    Re:Re:printing a single current record

    [Originally posted by Rich Thomas]

    What I'm trying to do. If I have 600 records in my criminal database. Now I have to add a new record to it. When I complete the datainput I need to print only that record. When I click on my print button (code)
    private sub CommandPrint_click()
    hardballdta.print

    The print cmd only print the first record in my database.
    I need to find some way to use a pointer to point to that record and print only that record.
    I'm using the VB forms for my datainput page and another form that looks like the forms that have to be fill by hard copy.

  4. #4
    Join Date
    Aug 2004
    Posts
    43,023

    Re:Re:Re:printing a single current record

    [Originally posted by gonzalo]

    ok, i suppost you have Access databases

    then you can find one record in all those 600 records by 2 ways

    first by finding a code, key, number, id depending on how you have organized your databases

    in that case, then you have to use this command

    databasecontroler.recordset.findfirst "whereveristhekeycodefield='" & text1.text & "'"
    if databasecontroles.recordset.nomatch then
    msgbox text1.text & " do not exist"
    else
    form.print
    endif

    this is by printing the form, i suppost you like to print the form and the picture, but if you only need to print a single record then use this procedure

    databasecontroler.recordset.findfirst "whereveristhekeycodefield='" & text1.text & "'"
    if databasecontroles.recordset.nomatch then
    msgbox text1.text & " do not exist"
    else
    printer.print databasecontroler.recordset("field with the key") & " " & databasecontroler.recordset("field with the name") & " " & format(databasecontroler.recordset("dateborn"),"DD/MM/YYYY") & " etc etc etc"
    printer.enddoc
    endif

    and other way if by filter the database

    Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
    if keycode = 13 then
    databasecontroler.recordsource="Select * from mytable where name like '*" & text1.text & "*'" ' note the *
    ' it mean "wherever is at the begin" and "wherever is at the end"
    datbasecontroler.refresh
    endif
    end sub

    private sub CommandPrint()
    if databasecontroler.recordset.recordcount>0 then
    printer.print databasecontroler.recordset("field with the key") & " " & databasecontroler.recordset("field with the name") & " " & format(databasecontroler.recordset("wherever date"),"DD/MM/YYYY") & " etc etc etc"
    printer.enddoc

    endif
    end sub

    to find those people by filter the database you'll need the databasecontroler and a grid to show you the results of the query
    in case you have 2 or 3 records then
    select the right row and click in the command buttom, this will print the record you just select
    or the first in case you dont select other record

    hope help

  5. #5
    Join Date
    Aug 2004
    Posts
    43,023

    Re:Re:Re:Re:printing a single current record

    [Originally posted by Rich Thomas]

    Thanks, That really works. I have been fighting this one or months. I can not thank you enough for the help that you have given me.

    Rich

  6. #6
    Join Date
    Aug 2004
    Posts
    43,023

    Re:Re:Re:Re:Re:printing a single current record

    [Originally posted by gonzalo]

    you try to find the help that you can about sql querys
    this will help you a lot

    gl

    gonzalo

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center