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

Division By Zero

Status
Not open for further replies.

Rubius

Programmer
May 12, 2000
57
0
0
CA
This is the SQL I have:<br>tempsql = &quot;SELECT PONumber, InvoiceNumber, Vendor, [Part Rec'd], NumofPieces, [Date Rec]&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;tempsql = tempsql & &quot; FROM [SR-LOG]&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;tempsql = tempsql & &quot; WHERE [Date Rec] Between &quot; & Me!date1 & &quot; And &quot; & Me!date2 & &quot;;&quot;<br><br>Use it to make a querydef. If I made a normal query it would display the records between the dates I enter so I know there should be data.<br>This line:<br>Set rst2 = qdfTemp.OpenRecordset(dbOpenDynaset, dbReadOnly)<br><br>Is what gets highlighted in yellow after it says division by zero. PLEASE tell me whats going on, I can't put up with this for very much longer. <br><br>-Stressed
 
I've got the following:<br><br>&nbsp;&nbsp;&nbsp;&nbsp;Dim dbs As Database<br>&nbsp;&nbsp;&nbsp;&nbsp;Dim qdfTemp As QueryDef<br>&nbsp;&nbsp;&nbsp;&nbsp;Dim tempsql As String<br>&nbsp;&nbsp;&nbsp;&nbsp;Dim rst2 As Recordset<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>then tempsql stuff<br>then..<br>&nbsp;&nbsp;&nbsp;&nbsp;Set qdfTemp = dbs.CreateQueryDef(&quot;&quot;)<br><br>&nbsp;&nbsp;&nbsp;&nbsp;qdfTemp.SQL = tempsql<br><br>and then the bad rst2 line where it stops..<br><br><br>thanks
 
You are missing the &quot;#&quot; around your date fields. The division by zero is caused by the year of &quot;00&quot; in your date fields.
 
Alrighty then...that worked...now that I look completly stupid, I'll ask this:<br><br>&nbsp;&nbsp;&nbsp;tempsql = &quot;SELECT PONumber, InvoiceNumber, Vendor, [Part Rec'd], NumofPieces, [Date Rec]&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;tempsql = tempsql & &quot; FROM [SR-LOG]&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;tempsql = tempsql & &quot; WHERE PONumber = &quot; & Me!ponumlog & &quot;;&quot;<br><br>everything the same as before but now I have a string that goes in the where section. When I run this, the query comes up with a question box. So it's like in a query when you put in critera and you would say &quot;Like [JobNumber:] and a box would appear before you run the query and you can type in the string you want it to display. <br>This comes up with that box with what whatever Me!ponumlog is in the place of [JobNumber:]...it's like I need it to have quotes around it..how can I do that?
 
jesus I got it..<br><br>tempsql = tempsql & &quot; WHERE PONumber = '&quot; & Me!ponumlog & &quot;';&quot;<br><br>gotta make it look like that....wow what a bad day today...<br>thanks for your help everyone.<br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top