Program to print a report / use database

Hi all.
I have a job here, and im no vb expert so i would like some ideas about the best way to do it. (by now, just for the concepts, not concerned about the code yet)

Basically, i have a database (created with sql server 2005) in a server with some informations about services executed by the company and some about the clients of the company.
Now, i have to make a program to the user add this informations in the db and print this informations in kind of report, in a very specific format. The program also have to allow user to consult old data. More: the informations in db canot be changed after printed, so all my program must do in db is include new informations and consult old ones, no need to update.

So, thats what im doing:
- first of all, i'm using bound controls, and not using 'data components' like DBGrid (i'm using ADODB.open and stuff...)
- so, i created a login form to validate the user in db. thats easy :)
- then i created a form where the user will enter the informations. im not sure whats the best way for that. i couldn't think of nothing but using textboxes for the user enter each information. (here i have to do some code, 'cause some of this informations fields are the sum of other ones. then, in this form, i use the values entered in some textbox to fill the value in another one). then i'll get those texts and execute the sql insert command.
- after that step, i need to print this informations. thats my biggest problem: that i have no idea how to do! (i've read about crystal reports, dont really understand how it works, but if possible, i'd rather use just VB for that)
the one think that come in mind is to add lots of labels in a form in the correct positions, load the captions with the new informations and then print it. but im quite sure thats not the best option!

So, as i dont know all the resources of vb, i really like some suggestions here. some components i could use, some tricks... Any help is welcome :)

Thanks all
[2081 byte] By [zezimtulli] at [2007-11-20 11:19:26]
# 1 Re: Program to print a report / use database
Explain more about your app. It sounds possible, but to eliminate problems, I'd get rid of the bound controls. That way, you can put any field on any control, and be able to format it easily.

If you are printing ID cards that's one thing, a report of items is another common report. Explain in detail.
dglienna at 2007-11-9 19:33:33 >
# 2 Re: Program to print a report / use database
hi dglienna, thanks for your reply.
i didn't understand why u suggest me to get ride of the bound controls. is there any problem using it? if so, what's the best way to do it?

i'll try to explain the problem a little bit more...
I don't wanna print the report in a blank paper, i'll use a paper with some informations already on it and i have to print on some empty places, to fill up the informations (like the description of the service, the price, the amount, etc). Those informations change for each report i'll print. There are other informations on the report that don't change (like the name of the company, the address, etc.) In that place i don't wanna print anything, because these are already on the paper...

i'm sending a picture of one page as an example. i had to erase some confidential info, but what i need is to print only where the red 'square' shows.

so that's what i want: in the app, the user will fill out the informations needed, then click to print. then, that typed informations must be saved on the db. after it, the fields must be printed in the correct place (only where there's a unfilled space, not where there's already some texts)

Hope it's better explained now.
Thanks a lot.
zezimtulli at 2007-11-9 19:34:36 >
# 3 Re: Program to print a report / use database
Here's a little trick to print, as well as print preview (just change printer to screen)

Sub PrintScreen()
Dim cpsplit() As String, cpcx As Long, h() As String
Dim m$, first As Boolean, prt$
cpsplit = Split(frmMain.txtOut, vbCrLf)
Printer.Font = "Arial"
Printer.Scale (0, 0)-(8.5, 11.5)
first = True
For cpcx = 0 To UBound(cpsplit) - 1
m = cpsplit(cpcx)
If cpcx > 0 Then
If InStr(m, " ") > 0 Then
Do While InStr(m, " ") > 0
m = Replace(m, " ", " ")
Loop
End If
h() = Split(m, " ")
If UBound(h) = 9 Then '
Printer.CurrentX = 1
Printer.FontBold = True
Printer.Print h(1);
Printer.FontBold = False
Printer.CurrentX = 1.5
Printer.Print h(2);
Printer.CurrentX = 2.5
Printer.Print h(3);
Printer.CurrentX = 3.5
Printer.Print h(4);
Printer.CurrentX = 4.5
Printer.Print h(5);
Printer.CurrentX = 5
Printer.Print h(6);
Printer.CurrentX = 5.5
Printer.Print h(7);
Printer.CurrentX = 6.5
Printer.Print h(8)
End If
End If
dglienna at 2007-11-9 19:35:40 >
# 4 Re: Program to print a report / use database
Hi dglienna, thanks again for your help.
But thats not what i want now... I'll save this for use in the future. What i need now is idea for the form itself, not the programming part, but the 'estruture' part, you know?
i'd like ideas for how to do the interface of the app, what components are better for each part of the app, what components to use for the user enter text and to store this text in db, what to use to show print preview... also I need to print just in the empty spaces in that picture on my last post, and i don't know what use for this: label? textbox? listbox? flexgrid?
that's the stuff i need to know now, the ideas for how to 'draw' the app.
So, any help is very welcome!

thanks.
zezimtulli at 2007-11-9 19:36:35 >
# 5 Re: Program to print a report / use database
Nobody? :confused:
zezimtulli at 2007-11-9 19:37:40 >
# 6 Re: Program to print a report / use database
Hi,

I usually use a dbgrid and a data control so that every time I refresh my information, or save, it is reflected on the dbgrid. that way it is easy to see whether the information is right before you print.

Why dont you use labels and text boxes for all the data you want to use then link the text boxes to the databses... get my drift? After that you can save them in a "new" table and excecute the querries or whatever else.

Hope that helps.

iagina
iagina at 2007-11-9 19:38:37 >
# 7 Re: Program to print a report / use database
See my code? No bound controls. I read a db, display data, have a flexgrid if they have to edit the data, and then it saves the data.

I use field() numbers, which closely coorelate with my controls on the form. Field(1) = txt(1) = Name (Also = h() for printing). That way, you can change the form at any time, as long as you hide and don't remove textboxes.
dglienna at 2007-11-9 19:39:36 >
# 8 Re: Program to print a report / use database
dglienna: i think there's a problem in your post. some code is missing.
you said about read a db, have a flexgrid, saves data, etc. but the code posted is just to print a textbox... did i misunderstood your post?
if you can post this app you said (.zip), it could help me to come up with some ideas for the look of the program.
thanks again
zezimtulli at 2007-11-9 19:40:45 >