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!

SQL and Code

Status
Not open for further replies.

JimConrad

Programmer
Feb 16, 2000
118
US
Looks like Me!RankBoxNum is null.<br>
<br>
By the way, unless you want to use code to iterate through the records in the query you are building, you don't need the Recordset variable. Just build the strSQL and assign it to the RecordSource property.<br>
<br>
Call me if you want: (734) 390-8482. <p>Jim Conrad<br><a href=mailto:jconrad3@visteon.com>jconrad3@visteon.com</a><br><a href= > </a><br>
 
OK I'm starting to get depressed! I followed everyone's directions and I'm still not striking gold. Here is the new code. Maybe I'm doing something wrong with the Form/Subform. I simply added the control (subform)onto my mainform, canceled the wizard, named the subform &quot;RaterSubForm&quot; and then added code to the mainform's current event. Below is what I'm now getting. I'm getting my fields/data from a query names OfficerQ. Any suggestions?<br>
<br>
Run-time error '3075' Syntax error<br>
(missing operator) in query expression '[RaterNum]= or[IntNum]= or[SeniorNum]='.<br>
<br>
Here is the code that is causing the error:<br>
<br>
Private Sub Form_Current() <br>
Dim db As Database, rst As Recordset, strSQL As String<br>
Set db = CurrentDb <br>
strSQL = &quot;SELECT [OfficerID],[LName],[FName],[MI],[Rank],[Unit]&quot;<br>
strSQL = strSQL & &quot; FROM OfficerQ WHERE [RaterNum] =&quot; & Me!RankBoxNum & _ &quot; Or [IntNum] =&quot; & Me!RankBoxNum & &quot; Or SeniorNum] =&quot; & me!RankBoxNum <br>
<br>
Set rst = db.OpenRecordset(strSQL) <br>
Me!RaterSubform.Form.RecordSource = strSQL<br>
<br>
rst.Close<br>
db.Close <br>
<br>
RaterComboBox.Requery<br>
InterComboBox.Requery <br>
SeniorComboBox.Requery<br>
<br>
End Sub <p>BF<br><a href=mailto:g43@tc3net.com>g43@tc3net.com</a><br><a href= > </a><br>
 
Your missing Bracket in front of &gt;&gt;&gt;&gt;&gt; SeniorNum] <br>
Now does your table conatian all of the fields in your SQL statement????<br>
<br>
Ok I got it to work. I made a dummy table and put in your fields But I added the bracket in front of SeniorNum] <br>
And I had to go add these fields<br>
[RaterNum] [IntNum] [SeniorNum] to my table<br>
but it did work.<br>
<br>
<p> DougP<br><a href=mailto: dposton@universal1.com> dposton@universal1.com</a><br><a href= > </a><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top