P
perky2go
I've created a report to use as a form letter; have a table containing the
records/fields needed in the letter; want to use a push button on a form to
set off merging the table data with the report to produce the letters. I
found a neat Replace() function that should build the contents of a label's
caption so that the basic ltr contents can be used for different occasions,
but I'm stymied in seeing if it will work because I can't get beyond Run Time
Error 438 (Object doesn't support this method or property) in recognizing my
reference to the label. It appears that the report needs to be open before I
can do anything with it, but opening the report didn't help with the error.
I'm using Access 97. Here's what I've got:
Function is on the Click event of the Form's command button
Table containing data is "LtrStaging"
Report name is "LtrRefund"
Label control is named "lblAddr"
Initial intent is to use the Replace() to string together the pieces of the
address (with one line or 2 for the street addr). The label contains
"tokens" for the address pieces, with "Provider" being the first, getting
it's data from the table field "PayToName".
Function FillOutLetter()
Dim D as database, R as recordset, C as control, Rpt as report
Set D = dbengine.workspaces(0).databases(0)
Set R = D.openrecordset("LtrStaging")
DoCmd.OpenReport "LtrRefund", acViewDesign
'Here's the line creating the error:
Set C = Reports.[LtrRefund].lblAddr
Do Until R.eof
C.Caption = Replace(C.Caption, "[Provider]", PayToName)
R.MoveNext
Loop
End Function
Here's the called function, placed in the FormModule:
Public Function Replace(Block, Token, ReplaceText)
Dim StartToken As String
Dim EndToken As String
Dim Front As String
Dim Back As String
StartToken = InStr(Block, Token) - 1
EndToken = StartToken + Len(Token) + 1
Front = Left(Block, StartToken)
Back = Mid(Block, EndToken)
Replace = Front & ReplaceText & Back
End Function
I'm probably missing some basic step/concept, but of course I don't know
what. Thanks!
records/fields needed in the letter; want to use a push button on a form to
set off merging the table data with the report to produce the letters. I
found a neat Replace() function that should build the contents of a label's
caption so that the basic ltr contents can be used for different occasions,
but I'm stymied in seeing if it will work because I can't get beyond Run Time
Error 438 (Object doesn't support this method or property) in recognizing my
reference to the label. It appears that the report needs to be open before I
can do anything with it, but opening the report didn't help with the error.
I'm using Access 97. Here's what I've got:
Function is on the Click event of the Form's command button
Table containing data is "LtrStaging"
Report name is "LtrRefund"
Label control is named "lblAddr"
Initial intent is to use the Replace() to string together the pieces of the
address (with one line or 2 for the street addr). The label contains
"tokens" for the address pieces, with "Provider" being the first, getting
it's data from the table field "PayToName".
Function FillOutLetter()
Dim D as database, R as recordset, C as control, Rpt as report
Set D = dbengine.workspaces(0).databases(0)
Set R = D.openrecordset("LtrStaging")
DoCmd.OpenReport "LtrRefund", acViewDesign
'Here's the line creating the error:
Set C = Reports.[LtrRefund].lblAddr
Do Until R.eof
C.Caption = Replace(C.Caption, "[Provider]", PayToName)
R.MoveNext
Loop
End Function
Here's the called function, placed in the FormModule:
Public Function Replace(Block, Token, ReplaceText)
Dim StartToken As String
Dim EndToken As String
Dim Front As String
Dim Back As String
StartToken = InStr(Block, Token) - 1
EndToken = StartToken + Len(Token) + 1
Front = Left(Block, StartToken)
Back = Mid(Block, EndToken)
Replace = Front & ReplaceText & Back
End Function
I'm probably missing some basic step/concept, but of course I don't know
what. Thanks!