D
Dustin I.
I'm trying to create a nicely formated Name and Address
text box to print on a report. I have created a function
in "module1" and in my report or sub I have code that
looks like :
DisplayAddress(ClientAddress)
txtAddress.Text = ClientAddress
When I first wrote the code I did not have any setfocus's
in there but got an error on that, now that I have added
setfocus on each control that I want to reference I get a
new error 2108 saying that I need to save the field.
Below is the code in my module. When I run this code
directly in a form it works, but when I reference it as a
function it fails, and I can not seem to get the code to
work directly in a report.
Sub DisplayAddress(strAddress)
Dim varName, varA1, varA2, varCity, varState, varZip As
String
Form_InvoiceEntry.clName.SetFocus
varName = Form_InvoiceEntry.clName.Text
Form_InvoiceEntry.clAdd1.SetFocus
varA1 = Form_InvoiceEntry.clAdd1.Text
Form_InvoiceEntry.clAdd2.SetFocus
varA2 = Form_InvoiceEntry.clAdd2.Text
Form_InvoiceEntry.clCity.SetFocus
varCity = Form_InvoiceEntry.clCity.Text
Form_InvoiceEntry.clState.SetFocus
varState = Form_InvoiceEntry.clState.Text
Form_InvoiceEntry.clZip.SetFocus
varZip = Form_InvoiceEntry.clZip.Text
strAddress = varName & vbCrLf & varA1
If Len(varA2) > 0 Then
strAddress = strAddress & vbCrLf & varA2 & vbCrLf
& varCity & " " & varState & " " & varZip
Else
strAddress = strAddress & vbCrLf & varCity
& ", " & varState & " " & varZip
End If
'txtAddressFormated.SetFocus
'txtAddressFormated.Text = strAddress
End Sub
Any help would be greatly appreciated.
Thanks
text box to print on a report. I have created a function
in "module1" and in my report or sub I have code that
looks like :
DisplayAddress(ClientAddress)
txtAddress.Text = ClientAddress
When I first wrote the code I did not have any setfocus's
in there but got an error on that, now that I have added
setfocus on each control that I want to reference I get a
new error 2108 saying that I need to save the field.
Below is the code in my module. When I run this code
directly in a form it works, but when I reference it as a
function it fails, and I can not seem to get the code to
work directly in a report.
Sub DisplayAddress(strAddress)
Dim varName, varA1, varA2, varCity, varState, varZip As
String
Form_InvoiceEntry.clName.SetFocus
varName = Form_InvoiceEntry.clName.Text
Form_InvoiceEntry.clAdd1.SetFocus
varA1 = Form_InvoiceEntry.clAdd1.Text
Form_InvoiceEntry.clAdd2.SetFocus
varA2 = Form_InvoiceEntry.clAdd2.Text
Form_InvoiceEntry.clCity.SetFocus
varCity = Form_InvoiceEntry.clCity.Text
Form_InvoiceEntry.clState.SetFocus
varState = Form_InvoiceEntry.clState.Text
Form_InvoiceEntry.clZip.SetFocus
varZip = Form_InvoiceEntry.clZip.Text
strAddress = varName & vbCrLf & varA1
If Len(varA2) > 0 Then
strAddress = strAddress & vbCrLf & varA2 & vbCrLf
& varCity & " " & varState & " " & varZip
Else
strAddress = strAddress & vbCrLf & varCity
& ", " & varState & " " & varZip
End If
'txtAddressFormated.SetFocus
'txtAddressFormated.Text = strAddress
End Sub
Any help would be greatly appreciated.
Thanks