On Double Click Event - Open to add instead of edit

L

Lori

I have a combo box set up. The pull down menu is a list that is tied to a
table "Titles". I have the event "On Double Click" set up to open that form
so the user can add a title if not already on the list.

Currently it opens and the first Title of the form shows up (edit mode). I
would like it to open to a new file. How would I do this? Do I add code to
the "On Open" event of the Title form or is there another way. Here is my
code. Thanks in advance.

Private Sub Title_DblClick(Cancel As Integer)
On Error GoTo Err_Title_DblClick
Dim lngTitle As Long

If IsNull(Me![Title]) Then
Me![Title].Text = ""
Else
lngTitle = Me![Title]
Me![Title] = Null
End If
DoCmd.OpenForm "frmContactTitles", , , , , acDialog, "GotoNew"
Me![Title].Requery
If lngTitle <> 0 Then Me![Title] = lngTitle

Exit_Title_DblClick:
Exit Sub

Err_Title_DblClick:
MsgBox Err.Description

End Sub
 
M

Marshall Barton

Lori said:
I have a combo box set up. The pull down menu is a list that is tied to a
table "Titles". I have the event "On Double Click" set up to open that form
so the user can add a title if not already on the list.

Currently it opens and the first Title of the form shows up (edit mode). I
would like it to open to a new file. How would I do this? Do I add code to
the "On Open" event of the Title form or is there another way. Here is my
code. []
DoCmd.OpenForm "frmContactTitles", , , , , acDialog, "GotoNew"
[]

Use the DataMode argument:

DoCmd.OpenForm "frmContactTitles", _
DataMode:=acFormAdd _
WindowMode:=acDialog
 
L

Lori

Thanks alot, it works...can you tell I'm new to access. Appreciate it!
--
Thank, Lori


Marshall Barton said:
Lori said:
I have a combo box set up. The pull down menu is a list that is tied to a
table "Titles". I have the event "On Double Click" set up to open that form
so the user can add a title if not already on the list.

Currently it opens and the first Title of the form shows up (edit mode). I
would like it to open to a new file. How would I do this? Do I add code to
the "On Open" event of the Title form or is there another way. Here is my
code. []
DoCmd.OpenForm "frmContactTitles", , , , , acDialog, "GotoNew"
[]

Use the DataMode argument:

DoCmd.OpenForm "frmContactTitles", _
DataMode:=acFormAdd _
WindowMode:=acDialog
 

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