Can't get this to work

  • Thread starter Afrosheen via AccessMonster.com
  • Start date
A

Afrosheen via AccessMonster.com

Thank you for taking the time to read this.
I have a combo box called cmboSupervisor. The control source is Supervisor
from the supervisor table.
I have an event {not in list} that is not working correctly. What I want to
have happen is when I enter a name {Joe} and it's not in the list, it will
ask me if I want to add it to the list. When I select yes then it's supposed
to put Joe in the Supervisor table and open the Supervisor form with Joe in
the supervisor field. Then be able to add more information. This is the code:

Private Sub CmboSupervisor_NotInList(NewData As String, Response As Integer)
Dim strMsg, stWhere As String
10 On Error GoTo CmboSupervisor_NotInList_Error
20 strMsg = "'" & NewData & "' is not in the Supervisor list. Are you sure
you want to add it?"
30 If MsgBox(strMsg, vbYesNo + vbDefaultButton2) = vbYes Then
40 Response = acDataErrAdded
50 DoCmd.OpenForm "copy of frmSupervisor", , , "Supervisor = " & Chr(34)
& NewData & Chr(34), , acDialog, NewData
60 Else
70 Response = acDataErrContinue
80 Me.cmboSupervisor.Undo
90 End If

100 On Error GoTo 0
110 Exit Sub

CmboSupervisor_NotInList_Error:

120 MsgBox "Error " & Err.Number & " (" & Err.Description & ") in
procedure CmboSupervisor_NotInList of VBA Document Form_frmEmployee_Tab"
End Sub

I don't know where the problem is and any help would be appreciated.
 
M

Marshall Barton

Afrosheen said:
I have a combo box called cmboSupervisor. The control source is Supervisor
from the supervisor table.
I have an event {not in list} that is not working correctly. What I want to
have happen is when I enter a name {Joe} and it's not in the list, it will
ask me if I want to add it to the list. When I select yes then it's supposed
to put Joe in the Supervisor table and open the Supervisor form with Joe in
the supervisor field. Then be able to add more information. This is the code:

Private Sub CmboSupervisor_NotInList(NewData As String, Response As Integer)
Dim strMsg, stWhere As String
10 On Error GoTo CmboSupervisor_NotInList_Error
20 strMsg = "'" & NewData & "' is not in the Supervisor list. Are you sure
you want to add it?"
30 If MsgBox(strMsg, vbYesNo + vbDefaultButton2) = vbYes Then
40 Response = acDataErrAdded
50 DoCmd.OpenForm "copy of frmSupervisor", , , "Supervisor = " & Chr(34)
& NewData & Chr(34), , acDialog, NewData
60 Else
70 Response = acDataErrContinue
80 Me.cmboSupervisor.Undo
90 End If

100 On Error GoTo 0
110 Exit Sub

CmboSupervisor_NotInList_Error:

120 MsgBox "Error " & Err.Number & " (" & Err.Description & ") in
procedure CmboSupervisor_NotInList of VBA Document Form_frmEmployee_Tab"
End Sub

I don't know where the problem is and any help would be appreciated.


What, exactly. is the problem?

We also need to see the code in the form
copy of frmSupervisor
particularly the code that processes OpenArgs.

It probably should be in the form's Load event and look
something like:

If Not IsNull(Me.OpenArgs) Then
Me.Supervisor = Me.OpenArgs
Me.Supervisor.Locked = True
End If
 
A

Afrosheen via AccessMonster.com

Ah, Thanks Marshall, I looked further in to the code on the frmSupervisor.
And guess what, Your code that you gave me was not in the frmSupervisor. But,
it is now.

I'll do some more checking and get back to you on Fri.

Marshall said:
I have a combo box called cmboSupervisor. The control source is Supervisor
from the supervisor table.
[quoted text clipped - 28 lines]
I don't know where the problem is and any help would be appreciated.

What, exactly. is the problem?

We also need to see the code in the form
copy of frmSupervisor
particularly the code that processes OpenArgs.

It probably should be in the form's Load event and look
something like:

If Not IsNull(Me.OpenArgs) Then
Me.Supervisor = Me.OpenArgs
Me.Supervisor.Locked = True
End If
 
A

Afrosheen via AccessMonster.com

Thanks for the help Marshall. I did not have that routine in the
frmsupervisor.

I really don't know where you and others get all their information so you can
help us. But, Thanks.
Ah, Thanks Marshall, I looked further in to the code on the frmSupervisor.
And guess what, Your code that you gave me was not in the frmSupervisor. But,
it is now.

I'll do some more checking and get back to you on Fri.
[quoted text clipped - 15 lines]
Me.Supervisor.Locked = True
End If
 

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