Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

why wont this work? 2 quick questions 1

Status
Not open for further replies.

LikeThisName

Vendor
May 16, 2002
288
US

trying to just call a report of through menubar

worked fine from switchboard

PROBLEM: docmd.openReport doesn't preview it just prints!?!
here is the code:

reportName is gotten from select statement

DoCmd.OpenReport (reportName)

also: this?

customize delete button based on record pulled
-------
Dim mystr As String
mystr = "Delete: " & Me.FirstName
Me.DeleteMember.Caption = mystr
 
Hi

First point:

DoCmd.OpenReport ("reportName",acViewPreview)

Second point, this will delete current record if placed in the click event of your button:

DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70

HTH Nigel
Didn't someone say work is supposed to be fun? They didn't have computers then I guess....
 

I get a compile errors: Expected =
acessing code different approach i get Syntax error.

DoCmd.OpenReport ("reportName",acViewPreview)

if you're still on, i could use your help.
 
solution to first problem:

remove paranthesis

reportName= "blah"
DoCmd.OpenReport reportName, acViewPreview

thanks mrf1xa for responding so quick earlier

asfar as the delete

i actually wanted to change caption of a button to reflect a field.

function changeButtonCaption()

Me.myButton.Caption = "Say hello to " & Me.Firstname
Me.myButton.Caption = "Say Hello to " & Me.Firstname.Value

end function

PROBLEM: can't get caption to have a field value. why not?

thanks, not as important as the preview question, now just curious.
 
Firstly apologies for bum steer on Printing- did it off top of my head and clearly memory is not what it used to be!

Out of interest I set up test db to look at other issue. Table has column called Name, simple form with text box txtName whose label is lblName.

I then came up with following in the OnCurrent event of the form and, hey presto, label changes every time you open form or change records on it.

No doubt need tweaking but might give a pointer the right way.

Dim str As String
If IsNull(Me.txtName) Then
str = "Sir"
Else
str = Me.txtName
End If

Me.lblName.Caption = "Hello to" & " " & str Nigel
Didn't someone say work is supposed to be fun? They didn't have computers then I guess....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top