Pampers;
In answer to your questions…
(1)It is better not to use # as in strClnt# (reserved);
beter would be something like ClientID. If so, should it not be ClientID” (without str)?
If strClnt# a reserved variable, I have not had any problems with it. However,
in using the “str” in front of the variable that signifies to me when I come back to work
on the program at a later date that the variable is a text string. I do agree that I probably
need to go back and rename the base field name removing the “#” from it.
(2) also there is a typo in your code:
DoCmd.OpenReport stDocName, acPreview,,stLnkCriteria
stLnkCritera, must be stLinkCriteria with an i
Thank you, I have noticed that as well and made the correction. Will have to keep a
Sharper eye out on the program before posting it to here.
(3)no need for “’”since it is a number
Actual it is a text string as it has numbers and letters in the Client Number field.
LaurieHamlin:
In response to your helpful comment…
“I’m also not sure I’m following what you’re doing, but I’ve had success with this
method. First filter the form. Then in the report create a text box which refers to the
value showing in the field in the form. I had to do this for a database when I couldn’t
print the form due to a known bug.
Hope that helps.”
Your comment does help and I believe that I have done perhaps half of that. What I
have is a form that lets me search for the client. I then have 4 buttons that direct me
to the 4 different tables I have for the client (these were created over the years and
I am working on getting all the tables into one) This brings up a filtered form that
Displays the client’s name and number with a subform for the data that pertains to
that client. From this filtered form I have a preview print button that is supposed to
bring up the report and display only the client that was shown in the filtered form.
My problem is that it brings up the report but displays All the clients with All their
Data.
As a side note, the Form/Sub form and Report are all generated by the same Client-qry
And Data-qry.
AceMan1:
The button is in the main form. And while using the [tblClient_ID] I would prefer to
Use the [strClntID] field string as we have some business clients that have changed their
Company’s name and makes it easier to keep those clients together.
Now what has happened when I have implemented the above suggestions is…
Pampers suggestion of changing the [strClnt#] field in the Table Object.
I changed the Field name from [strClnt#] to [strClntID] in the Table Object I had to go
through all the queries, forms and change out the fields as well as recreate the Reports. Took
some time but was able to get everything back up and running as it had before I did the
changeover. I have already taken care of the type, the new program is below.
LaurieHamlin
I did create a text box in the Report that tied to the filtered form that I am using to call up the report.
The result of this is that the report comes up with every client on record with proper Client ID Number
As well as the text box showing the Client ID Number that I want to show.
That is, every client is now showing the same Client ID Number that I had Filtered in the form.
AceMan1
As a last resort I will use the tblClient_ID which is the record number, but I would prefer to use the
Client ID Number as I said above.
Here is the Program to call up the report as it stands now. (06-16-05 at 02:55 pm *1455 24hr time*)
Private Sub cmdPrevRpt_Click()
On Error GoTo Err_cmdPrevRpt_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "rptClientDetail"
stLinkCriteria = "[strClntID] = " & Me![strClntID] & ""
DoCmd.OpenReport stDocName, acPreview, stLinkCriteria
Exit_cmdPrevRpt_Click:
Exit Sub
Err_cmdPrevRpt_Click:
MsgBox Err.Description
Resume Exit_cmdPrevRpt_Click
End Sub