After asking a few questions on this forum about different procedures it has become evident that one must have some knowledge about inserting SQL into code. Although I understand the concept, I'm having difficulty figuring out where to put all those d@mn quotes. Can someone point out a good reference or give a quick tutorial on this process and also help me with the code below? For example:<br>
<br>
Private Sub Form_Current()<br>
Dim db As Database, rst As Recordset, SQL As String<br>
Set db = CurrentDb<br>
<br>
SQL = "SELECT [OfficerID], [LName], [FName], [MI], [Rank], [Unit]"<br>
SQL = SQL & "FROM OfficerQ WHERE [RaterNum] Or [IntNum] Or [SeniorNum] = " & Me!RankBoxNum<br>
Set rst = db.OpenRecordset(SQL)<br>
<br>
Me![RaterSubform].Form.RecordSource = SQL<br>
<br>
rst.Close<br>
db.Close<br>
<br>
end sub<br>
<br>
This is attached to a main form current event. My desire is for the results to go into a subform called "RaterSubForm". The main form is called OfficerF. When I run it I'm getting an error on the Me![RaterSubForm].Form.RecordSource line. However, I feel I may also have some syntax errors in the SQL string. The SQL statement will run against a query called raterQ that is built from two tables.<br>
<br>
Please don't tell me to go to the Access help file. Been there! Done that!<br>
<br>
Thanks<br>
BF <p>BF<br><a href=mailto:g43@tc3net.com>g43@tc3net.com</a><br><a href= > </a><br>
<br>
Private Sub Form_Current()<br>
Dim db As Database, rst As Recordset, SQL As String<br>
Set db = CurrentDb<br>
<br>
SQL = "SELECT [OfficerID], [LName], [FName], [MI], [Rank], [Unit]"<br>
SQL = SQL & "FROM OfficerQ WHERE [RaterNum] Or [IntNum] Or [SeniorNum] = " & Me!RankBoxNum<br>
Set rst = db.OpenRecordset(SQL)<br>
<br>
Me![RaterSubform].Form.RecordSource = SQL<br>
<br>
rst.Close<br>
db.Close<br>
<br>
end sub<br>
<br>
This is attached to a main form current event. My desire is for the results to go into a subform called "RaterSubForm". The main form is called OfficerF. When I run it I'm getting an error on the Me![RaterSubForm].Form.RecordSource line. However, I feel I may also have some syntax errors in the SQL string. The SQL statement will run against a query called raterQ that is built from two tables.<br>
<br>
Please don't tell me to go to the Access help file. Been there! Done that!<br>
<br>
Thanks<br>
BF <p>BF<br><a href=mailto:g43@tc3net.com>g43@tc3net.com</a><br><a href= > </a><br>