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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

COMBO BOX SELECTION

Status
Not open for further replies.

villica

Programmer
Feb 25, 2000
332
CA
I have a combo box that displays all the tables in my database. Every table has a field for INITIALS. When the user picks a table they also have to pick the initials in another combo box and then displays a crosstab report. <br>
I have this procedure on my on click preview report.<br>
<br>
Dim stDocName As String<br>
Dim strlinkcriteria As String<br>
<br>
stDocName = [Forms]![frmlogdate]![logfile] // combo box for tables<br>
If IsNull(stDocName) Then // check if user selects a tb<br>
MsgBox &quot;Please select the Logfile from the List.&quot;<br>
Else<br>
Me.Visible = False<br>
strlinkcriteria = INITIALS = [Forms]![frmlogdate]! [iNITIALS]<br>
DoCmd.OpenReport &quot;CrossTab&quot;, acPreview, , strlinkcriteria<br>
End If<br>
<br>
<br>
My problem is that I get an error msg saying that it is an invalid use of null and also the report does now show anything. I am comparing the initials from the table they pick to the initials they want to see for the report which is in another combo box on the same form. What is wrong with this code. Please help. <p>Villica<br><a href=mailto:villica67@hotmail.com>villica67@hotmail.com</a><br><a href= > </a><br>
 
I think there are two mistakes in the codes.<br>
1. You can not declare stDocName as string. It has to be declared as variant if it is possible for it to be assigned a null value.<br>
2.the line of code &quot;strlinkcriteria = INITIALS = [Forms]![frmlogdate]! [iNITIALS]&quot; is not right. I propose the following code:<br>
strlinkcriteria = &quot;INITIALS =&quot; & cstr([Forms]![frmlogdate]! [iNITIALS])<br>
<br>
I hope this can help.<br>
<br>

 
Hi I tried your sugestions but it does not work. I was wondering, my report does not have any control source but I don' t think there is a way of creating control source because I am not attaching a specific table or a query. I just basically created a report that contains some summary fields and the initials. I did change my variable to variant and it works perfect. If you can think any sugestions please let me know.<br>
<br>
Me.Visible = False<br>
DoCmd.OpenTable stDocName, acViewPreview<br>
strlinkcriteria = &quot;INITIALS = &quot; & cstr([Forms]![frmlogdate]![INITIALS])<br>
DoCmd.OpenReport &quot;CrossTab&quot;, acPreview, , strlinkcriteria<br>
Thank you <p>Villica<br><a href=mailto:villica67@hotmail.com>villica67@hotmail.com</a><br><a href= > </a><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top