View Full Version : display the selected data on report through a from


kalia
03-25-2010, 06:08 AM
hello everyone
i made a table named Registration the primery key of this table is Registration No and a form named registration to enter the data in that table now i want to dispaly that data through a from on a report or another form like i design a from having a textbox named Registration No and a command button named preview all i want is to enter the registration no in that textbox and on cliking the preview button all the data relevent to that registration no should dispaly sepradly on another form or report.
Note: data must display as i made my registration form
i m a new user to access database plez help me step by step that how, what and where i should write the command or code

pbaldy
03-25-2010, 08:30 AM
This should give you a start:

http://www.baldyweb.com/wherecondition.htm

The code would go behind the button.

kalia
03-25-2010, 09:24 AM
i read it for ten times but i dont get it means how to do this step by step like should i first creat a report of Registration table & then a form containing one text box and one command button and write the following code in onclik event proceture in vb..?

pbaldy
03-25-2010, 10:30 AM
Yes, first you would create a second form or a report that returns all records. Whether you use a form or report depends on whether you want the user to be able to edit the data or just view it. Then use code from the link using either OpenForm or OpenReport as appropriate.

kalia
03-25-2010, 10:50 AM
i creat a report named Registration Detail and write the following code in envent procedure of onclick property of cammand bottun

Option Compare Database

Private Sub Command8_Click()
DoCmd.OpenReport "[Registration Detail]", , , "[Registration No] = " & Me.textreg
End Sub
Note: textreg is the name of textbox

but its shows runtime error '2103': the report name '[Registration No]' you entered in either the property sheet or macro is misspelled or reffre to report that doesn't exist. plz help

kalia
03-25-2010, 11:34 AM
hey i set the code as

Option Compare Database

Private Sub Command9_Click()
DoCmd.OpenReport "Registration Detail", , , "[Registration No] = '" & Me.textreg & "'"
End Sub

but it starts printing automateically instead of viewi havent a printer lolz i just want to view

pbaldy
03-25-2010, 12:50 PM
Look in VBA help at OpenReport; one of the arguments controls whether it prints or previews. The default is to print.

kalia
03-25-2010, 01:59 PM
i don't understand this plz simplyfy this statment i m done but this thing occur atometically prints plz help me and thank for the rest of help

pbaldy
03-25-2010, 02:19 PM
Did you even look in help?

DoCmd.OpenReport "Registration Detail", acViewPreview, , "[Registration No] = '" & Me.textreg & "'"

kalia
03-25-2010, 02:44 PM
ohhh thanks a lot i m so excited thanks u solve a big problem i wish to hug u
can i use this serch box for other reports if yes then how

vbaInet
03-25-2010, 02:54 PM
ohhh thanks a lot i m so excited thanks u solve a big problem i wish to hug uNevada - Tennessee, USA. I've got to warn you though, he's married :D

pbaldy
03-25-2010, 03:08 PM
Hey, why are you interfering with my fun?!?

THUD!!

Ouch; sorry honey, I was just kidding. :p

I must be blind; don't see Tennessee referred to anywhere. :confused:

In any case, Tennessee is about 12 UK's from here. :D

SOS
03-25-2010, 03:08 PM
Nevada - Tennessee, USA.

???????? Nevada - Tennesee?????

Nevada is the state, just like Tennessee is a state and they are both over 2,000 miles apart.

SOS
03-25-2010, 03:08 PM
Now I'm the slow fingered one :D

vbaInet
03-25-2010, 03:18 PM
Paul, I don't know where the Tennessee came from. It could be the Jack Daniels I'm currently sipping. Ahhh....! :)

SOS keep up. I know Paul is long in the game, but keep up. lol.

SOS
03-25-2010, 03:29 PM
SOS keep up. I know Paul is long in the game, but keep up. lol.
I think it is a losing battle anyway. But we keep trying. :)

vbaInet
03-25-2010, 03:31 PM
Paul has raised the stakes too high. We shall keep trying. :)

pbaldy
03-25-2010, 03:36 PM
I know Paul is long in the game

Oh, so now it's going to be the "old geezer" jokes?!? :D

SOS
03-25-2010, 03:38 PM
Oh, so now it's going to be the "old geezer" jokes?!? :D
Well, if the Shoe Fits (or the Foo Sh...) :D :) ;)

vbaInet
03-25-2010, 03:39 PM
I see you picked up some cockney slang whilst here? :) hehe!

kalia
03-26-2010, 02:19 AM
i ask that can i use the same form for other reports.....?

pbaldy
03-26-2010, 07:00 AM
Sure, any number of ways. Different buttons for each report, a combo or listbox to choose which report, etc.

kalia
03-26-2010, 08:53 AM
can i creat command button and a text box in switchboard if yes then how

pbaldy
03-26-2010, 09:05 AM
I'll let somebody else field that, as I don't use switchboards (and the question is a little vague).

kalia
03-26-2010, 09:44 AM
Sure, any number of ways. Different buttons for each report, a combo or listbox to choose which report, etc.

if i use sperad button for each report on that form that will look like 5 buttons and five textbox i mean not that much good. As u said combo box or list box that will be fine but what how will be the code for every report if i use only one commad button and one text box plz help or is this possible that on each report when i clik this form open insted of open report and i give the id and it serch for that report like when i clik on registration report and give registration no in form and clik buttun and it brings the data from registration report and when i clik on another report and the same form open and i give the filed name like id and it brings the data from that report and so on simply one from one text button and one command button for multiple reports plz tell me step by step procedure

pbaldy
03-26-2010, 09:55 AM
If you had a combo or listbox that displayed the available reports, the code would look like:

DoCmd.OpenReport Me.ComboName,...

That presumes that the actual report name is in the bound column of the combo.

kalia
03-26-2010, 11:26 AM
i have 6 reports named

Registration Detail
Reunification Detail
Referal Deatail
Counseling Detail
Attendance Detail
Reunification follow ups Detail

all these reports will i select in a combox and then i will have one text box and one command button now u mean i will write
DoCmd.OpenReport Me.ComboName, acViewPreview, , "[Registration No] = '" & Me.textreg & "'" in the event procedure of button comand is it right..? and what will be expression for these reports to select in combox i dont know about selecting report in combox because combo box only select tables and there values....another thing acViewPreview the report in print preview what will be the cammand if i want to see the report in normal view