×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

How can I have text box report name get inside my form button?
2

How can I have text box report name get inside my form button?

How can I have text box report name get inside my form button?

(OP)
I would like to replace the Dlookup that appears in the On Click Events procedure.
The purpose was to lookup the report name for a given place.

Instead, I have figured out how to get the desired report name to appear automatically
in the same form in a Text Box using ..... =[cboReportNumber].[Column](1)

For example, the report name might be .... rptTicketIndCharter
So the new sReportNameSpl would use this rpt name. Thanks, Glen

Here is what I have presently.

Private Sub cmd1171_Click()

On Error GoTo Err_cmd1171_Click

Me.Refresh

Dim sReportNameSpl As String

sReportNameSpl = DLookup("Reportname", "tblreport", "[BusnID] = " & Me.BusnID _
& " And [resort#] = " & Me.ResortID & " And [ReportNum] = " & Me.cboReportNumber)

DoCmd.OpenReport sReportNameSpl, acViewPreview

DoCmd.Maximize

Exit_cmd1171_Click:
Exit Sub

Err_cmd1171_Click:
MsgBox Err.Description
Resume Exit_cmd1171_Click

End Sub

RE: How can I have text box report name get inside my form button?

Are you simply looking for something like:


CODE --> VBA

sReportNameSpl = Me.[cboReportNumber].[Column](1) 

It seems a bit odd to me that you would have many reports that might be the same but for different places.

Duane
Minnesota
Hook'D on Access
MS Access MVP 2001-2016

RE: How can I have text box report name get inside my form button?

And, as far as "report name get inside my form button?"
Do you mean a Caption of your command button:

CODE

...
sReportNameSpl = Me.[cboReportNumber].[Column](1) 
cmd1175.Caption = sReportNameSpl
... 

BTW - do you have over 1100 command buttons on your Form? ponder


---- Andy

There is a great need for a sarcasm font.

RE: How can I have text box report name get inside my form button?

(OP)
Hi Duane - Lol. We have many resort place and they tend to request their report format. A pain in the butt.
So we have one qry that fits all but say a need to retrieve 40 different reports depending on the resort.

I use a number system for my work. The form buttons use the same button.

I will try your method. It is so appreciated. I see that Andrzejek has something similar.
I cannot try this till Weds. I will let you know how I made out.

Regards, Glen

RE: How can I have text box report name get inside my form button?

(OP)
12/14/18 I get an error message.
It says "undefined function Dlookup in expression. glen


Here is what I have on the events button:


Private Sub cmd1171_Click()

On Error GoTo Err_cmd1171_Click

Me.Refresh

Dim sReportNameSpl As String

sReportNameSpl = Me.[cboReportNumber].[Column](2)

DoCmd.OpenReport sReportNameSpl, acViewPreview

DoCmd.Maximize

Exit_cmd1171_Click:
Exit Sub

Err_cmd1171_Click:
MsgBox Err.Description
Resume Exit_cmd1171_Click

End Sub

RE: How can I have text box report name get inside my form button?

"I get an error message." and which line of your code is highlighted?

Do you use/have Option Explicit at the top of General Declaration section?


---- Andy

There is a great need for a sarcasm font.

RE: How can I have text box report name get inside my form button?

I don't see any reference to DLookup().

Do you know how to debug with setting breakpoints to step through your code or using Debug.Print or Msgbox().

what is the value of sReportNameSpl?

Duane
Minnesota
Hook'D on Access
MS Access MVP 2001-2016

RE: How can I have text box report name get inside my form button?

(OP)
Sorry for being so dopey. It works. I forgot to pick something. Operator Error.

Thanks guys for helping me out. Cimoli Glen

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close