Adding to a Combo Box list

  • Thread starter Qdxss2b via AccessMonster.com
  • Start date
Q

Qdxss2b via AccessMonster.com

I am trying to add new info to a combo box list.

On a form called frmGenInfo which lists Employees, work sites, and general
information about the employee.

This is based a table called tblUpdates.
It draws from 3 tables, tblEmployee, tblWorkSite, tblGenInfo.

I have put a command button on the form so that I can add a new employee.
This is on the click command:
(I have skipped putting in the error handling lines)
Private Sub cmdAddEmployee_Click()

Dim NbrEmployeeID As Long

If IsNull (EmployeeID) Then
EmployeeID = ""
Else
NbrEmployeeID = EmployeeID
EmployeeID = Null

End If

Do.Cmd.Open Form "frmEmployee", , , , , AcWindowMode.acDialog, "GotoNew"
EmployeeID.Requery

If NbrEmployeeID <> 0 Then
EmployeeID = NbrEmployeeID
End If

End Sub

The problem is that when it opens the form, it does not go to a new record.
It opens and goes to the first record in the table tblEmployee.
What am I doing wrong?

Thank you for any help.
 
S

Stefan Hoffmann

hi,

Do.Cmd.Open Form "frmEmployee", , , , , AcWindowMode.acDialog, "GotoNew"
You should copy and past compiled code - in the menu 'Debug\Compile'.
'Do.Cmd.Open' should raise an error.
The problem is that when it opens the form, it does not go to a new record.
It opens and goes to the first record in the table tblEmployee.
What am I doing wrong?
You have two possibilities:

1) Use the correct data mode, e.g.

DoCmd.OpenForm "frmEmployee", , , , acFormAdd, acDialog

or

2) Correct your code in the form open/load event. The usage of the
OpenArgs parameter indicates that you wanted to do something like
(untested):

Private Sub Form_Load()

If Not IsMissing(Me.OpenArgs) And Me.OpenArgs = "GotoNew" Then
DoCmd.GoToRecord , , acNewRec
End If

End Sub



mfG
--> stefan <--
 
Q

Qdxss2b via AccessMonster.com

DoCmd.OpenForm "frmEmployee", , , , acFormAdd, acDialog

I tried adding the acFormAdd and it worked like a charm.

Thank you very much. I have been fighting with this for two days and just
couldn't figure out what I was missing.

Raymond
 

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