Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
If-Then Help! Simple Situation it seems
This question is hard to explain so i will show you an example:
dim strng as string Set find = CurrentDb.OpenRecordset("Name", dbOpenDynaset) find.MoveFirst If chkJob.value = -1 Then If Len(strng) = 0 Then strng = "find!title = " & cboJobtitle Else strng = strng & " AND find!title = " & cboJobtitle End If End If If chkyears.value = -1 Then If Len(strng) = 0 Then strng = "find!yrs = " & txtYrs Else strng = strng & " AND find!yrs = " & txtYrs End If End If .. .. .. Do Until find.EOF If strng Then ReDim Preserve names(x) names(x) = find!id x = x + 1 End If loop Im getting a data type runtime error#13 at the bottom where it trys to do the "if strng then" within the loop. Does anyone have any suggestions. it would help me out alot. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
If-Then Help! Simple Situation it seems
You can't pass a string argument to IF and expect it to be evaluated as if
you had previously written the command out. You will have to incorporate the boolean logic portion of your previous If Then statements into the looping statement rather than building such a string. -- Regards, Tom Ogilvy "Brandon Johnson" wrote: This question is hard to explain so i will show you an example: dim strng as string Set find = CurrentDb.OpenRecordset("Name", dbOpenDynaset) find.MoveFirst If chkJob.value = -1 Then If Len(strng) = 0 Then strng = "find!title = " & cboJobtitle Else strng = strng & " AND find!title = " & cboJobtitle End If End If If chkyears.value = -1 Then If Len(strng) = 0 Then strng = "find!yrs = " & txtYrs Else strng = strng & " AND find!yrs = " & txtYrs End If End If .. .. .. Do Until find.EOF If strng Then ReDim Preserve names(x) names(x) = find!id x = x + 1 End If loop Im getting a data type runtime error#13 at the bottom where it trys to do the "if strng then" within the loop. Does anyone have any suggestions. it would help me out alot. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
What Should I do in this situation | New Users to Excel | |||
Time Situation | Excel Worksheet Functions | |||
Nested IF in this situation | Excel Worksheet Functions | |||
need help with a If=then situation. | Excel Programming | |||
Best function for my situation | Excel Worksheet Functions |