How open a form with a blank record

D

Dave

I have a form that I create/edit orders on. I also have a form that I
create/edit vendors on.

On the orders form there is a drop down list of vendors to assign to the
order. There is also a button I can click to open the vendor form. If there
is already a vendor assigned to the order (i.e. there is one selected in the
drop down box), the vendor form opens with this record for editing. If
there is no vendor assigned, I want the vendor form to open with a blank
record so a new vendor can be created.

What I cannot figure out is how to get the venndor form to open with a blank
record.

Here is the guts of my current code behind the button click event...

stDocName = "vendor"

If Len(Me![cboVendorID]) > 0 Then
stLinkCriteria = "[vendorid]=" & Me![cboVendorID]
DoCmd.OpenForm stDocName, , , stLinkCriteria
Else
DoCmd.OpenForm stDocName
End If

It is the "else" code that is the problem. As written it opens the vendor
form with _all_ vendor records positioned on the first record. I want it to
open on a blank record and not include any other vendor records.

Can somone tell if this is possible and if so how I can do it?

Thanks
Dave

PS this is an Access 2000 file format ADP project pointing to a SQL Server
2000 database.
 
D

Daniel Pineault

If you look at the help for the OpenForm method you'll see that one of the
input variables is Datamode.

So try something like

stDocName = "vendor"

If Len(Me![cboVendorID]) > 0 Then
stLinkCriteria = "[vendorid]=" & Me![cboVendorID]
DoCmd.OpenForm stDocName, , , stLinkCriteria
Else
DoCmd.OpenForm stDocName, , , , acFormAdd
End If
--
Hope this helps,

Daniel Pineault
http://www.cardaconsultants.com/
For Access Tips and Examples: http://www.devhut.com
Please rate this post using the vote buttons if it was helpful.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top