Listbox to create where cond, but no records

B

Biggles

I have been using a listbox to select from a list of applications (developed
using Allen Browne's pages) and cycling through the selections to develop the
where condition. This works fine when there are records in the recordsource
of the opened form, but if there are no records, I don't know how to create a
new record with the appropriate id. This is the current code for the list
box:

For Each varnumber In Selectapp.ItemsSelected
sfilt = sfilt & Selectapp.ItemData(varnumber) & ","
appname = appname & Selectapp.Column(1, varnumber) & " and "
Next

'remove trailing comma, add field name, in operator, and brackets
lngLen = Len(sfilt) - 1
If lngLen > 0 Then
sfilt = "[txtapp_id] in (" & Left$(sfilt, lngLen) & ")"
End If
lngLen2 = Len(appname) - 5
If lngLen2 > 0 Then
appname = Left(appname, lngLen2)
End If
DoCmd.close
DoCmd.OpenForm stDocName, acNormal, , sfilt, , , appname


I cannot use the open args since that is bringing the description (appname)
into the next file to use as the caption.

Since the above creates a filter that looks like:
txtapp_id in (7) '7 being a valid app_id
My first thought was to parse the application id out of the where condition,
but I do not know how to reference it in the target form (where I have some
on open commands if there is no record). This, not surprisingly, did not
work:

'txtAPP_ID = Mid(Me.Filter, Len(Me.Filter) - 2, 1)

Any ideas, hope that makes some sense.
 
Top