Print Selected Record from Subform in Switchboard

navi87

New member
Local time
Today, 19:34
Joined
Apr 1, 2015
Messages
9
Greetings!

I have just joined (look for my Intro post ) after looking through the forum looking for a solution for my problem in my database...I didnt see anything that applied to my situation.

Now the fundamental point of my Database is to take bookings, calculate the costs and print out the bills.
It all works jim dandy...BUT I havent done it in a elegant way.
So I just want to streamline the database and make it more user friendly so my Dad could also use it.

I have a Switchboard with Buttons which functions as Navigation and below that I have a subform which is based on query from my Bookings table to show my current, future bookings etc.

I want to be able to click on a record in the subform and press a button to open the report in print preview mode without having to input the booking nr.

Funnily enough I have actually found an example database which has this function but its more complex (it does it in 2 stages, so the user can still input more data in the report if required) rather than going directly to the print preview. I cant get my head around in. I looked through the settings but its difficult when you dont really know what to look out for.

I have tried 2 things so far:

-Creating a macro with the OpenReport command but when I ran the macro it still wanted the Booking Nr manually inputted.
- I tried a VBA code but that gave me errors and I wasnt able to debug it.

I read some things regarding the "Link Child/Master Field" but I dont know if I even need that...I *think* that is more for pulling info from the Master form to show the related data in the subform.

I got a feeling ive left out vital info which you guys need in order to help me out, just let me know what it is you need

Thanks,

Navi
 
im not sure this is what I need. I read through it but it will only filter the data and not put it into a report, correct?
Theres second page which seems more suitable with the following code:

Dim rs As Object Dim lngBookmark As Long 'set a variable to the current record lngBookmark = Me.txtEmpID 'open the new form DoCmd.OpenForm "frmEmployeesDetail" 'take it to the selected record Set rs = Forms!frmEmployeesDetail.RecordsetClone rs.FindFirst "EmpID = " & lngBookmark Forms!frmEmployeesDetail.Bookmark = rs.Bookmark Set rs = Nothing

Forms!frmEmployeesDetail.txtEmpID = Me.txtEmpID




Im not sure which are the variables I need to changed.

I want it to copy the Booking Nr from the Booking table or from my Forms (either is fine)
The Report I want to open is "report_confirmation"

any thoughts?

I would include screenshots but I still have yet to hit the 10 post mark
 
It would open the report filtered to the record selected on the form. Along the lines of:

DoCmd.OpenReport "report_confirmation", acViewPreview, , "[Booking Nr] = " & Me.[Booking Nr]

You'll find in the long run spaces and symbols in your names aren't worth the bother.
 
Yes the long names of the forms etc are starting to annoy me lol

Right ok I just tried that code but I receive an run-time error 2465

"Cant find the field "|" referred in your expression"


Does the subform maybe need to be configured in a particular way??
 
Make sure the field and control names are correct; I just guessed at them.
 
The field name was correct.
The control name would be the name of the subform I am trying to extract the Booking number from, correct?
 
im not going to lie...I dont really understand that site.

:banghead: lol


- The main form is called Switchboard
- the subform is on the Switchboard and its called switch_all_bookings. This form is based on a query....does that maybe have any influence? No Criteria is set...I just needed info from two tables into one form (Booking Details+Customer Details)
- in the form switch_all_bookings the field that I need is called Booking Nr.

I just tried out:

DoCmd.OpenReport "report_confirmation", acViewPreview, , "[Booking Nr]=" & [switch_all_bookings]

Then it says there is a type mismatch.

I got a feeling there is just a very small issue here...
 
Try this if booking number is text:

DoCmd.OpenReport "report_confirmation", acViewPreview, , "[Booking Nr]='" & [switch_all_bookings] & "'"
 
Try this if booking number is text:

DoCmd.OpenReport "report_confirmation", acViewPreview, , "[Booking Nr]='" & [switch_all_bookings] & "'"

The Booking Nr is of numeric value.

In that expression above we are basically saying
1. open report confirmation
2. in preview mode
3. The value of Booking Nr is found in the "switch_all_bookings" subform.


If my understanding is correct then it should work...
its gettin kinda late...thanks for your efforts but I think im gonna call it a night...i will give it another go tomorrow with a fresh head :)
 
The type mismatch error implies its data type is text (though it may contain numeric values). Post back tomorrow if that didn't work. Post the db if it doesn't work (if you're able).
 
The type mismatch error implies its data type is text (though it may contain numeric values). Post back tomorrow if that didn't work. Post the db if it doesn't work (if you're able).

Im pretty sure the field is an AutoNumber (thats what it is set at in the table)

Ill test it out once I get home.
 

Users who are viewing this thread

Back
Top Bottom