Solved Open form to spesific record or add it

npa3000

Member
Local time
Today, 22:20
Joined
Apr 16, 2021
Messages
36
Well, I have my order form and a button which it should open us the invoice form for this spesific order, if exists or add new record (invoice data)

How can i combine these two functions?
 
One idea would be to use the same (order form), but either open it acFormAdd or else open not as acFormAdd and with openargs (or set recordsource immediately after opening to that ID #)
 
put an unbound 'find' box in your form that shows all data.
when user enters the Order# , it filters to the record. If not there, click the ADD NEW button on the record selector.

Code:
sub txtBox_afterupdate()
if isNull(txtBox) then
   me.filterOn = false
else
   me.filter = "[OrderNum]='" & txtBox & "'"
   me.filterOn = true
endif
end sub
 
Maybe something like this:
Code:
Dim boOrderExists As Boolean

boOrderExists = IIf(DCount("*", "[tblOrders]", "[OrderID]='" & Me.OrderID) = 0, False, True)

If boOrderExists Then
    DoCmd.OpenForm "frmYourOrderForm", , , "[OrderID]=" & Me.OrderID
Else
    DoCmd.OpenForm "frmYourOrderForm", , , , acFormAdd
End If
 
using OpenArgs to set the Invoice recordset.
 

Attachments

Users who are viewing this thread

Back
Top Bottom