A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Adding to a Combo Box list



 
 
Thread Tools Display Modes
  #1  
Old April 4th, 2010, 03:35 PM posted to microsoft.public.access.forms
Qdxss2b via AccessMonster.com
external usenet poster
 
Posts: 2
Default Adding to a Combo Box list

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.

--
Message posted via http://www.accessmonster.com

  #2  
Old April 4th, 2010, 03:57 PM posted to microsoft.public.access.forms
Stefan Hoffmann
external usenet poster
 
Posts: 991
Default Adding to a Combo Box list

hi,

On 04.04.2010 16:35, Qdxss2b via AccessMonster.com wrote:
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 --
  #3  
Old April 4th, 2010, 05:38 PM posted to microsoft.public.access.forms
Qdxss2b via AccessMonster.com
external usenet poster
 
Posts: 2
Default Adding to a Combo Box list


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

--
Message posted via http://www.accessmonster.com

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 10:31 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.