Undo Itemcode


S

SG

I have the following behind a list box on a subform but it does not see to be working the vbNo section, if I select No the itemcode which the user typed in should be undone but nothing is happening any ideas anyone??




Private Sub itemcode_NotInList(NewData As String, Response As Integer)


If MsgBox("The Itemcode cannot be found enter now?", _
vbYesNo) = vbYes Then
DoCmd.OpenForm "enter new product details", , , , acFormAdd, acDialog, NewData
Response = acDataErrAdded

If vbYesNo = vbNo Then
Me.Undo
Cancel = True

Else
Response = acDataErrContinue
End If

End If

End Sub



Many Thanks


S
 
Ad

Advertisements

S

SG

Damian,

Perfect - Thankyou

If I answer yes the the question how can I copy the itencode typed in by the
user and have this displayed in the itemcode field of the "Enter New Product
Details" form to avoid the user having to type the itemcode again?

Thanks for the help!

S
 
G

Guest

Hi again SG,

Depending on where else you can open the add item form from, you could pass
the value as a parameter to the form, or you could have an on open event that
grabs the value from your other form eg:

me.txtItemCode = forms!OTHERFORM.ItemCode

Hope this points you in the right direction.

Damian.
 
A

AccessVandal via AccessMonster.com

Hi SG,

There is no Event called NotInList for ListBox. Did you mistook it for a
ComboBox?
 
S

SG

You are correct I allways get the 2 mixed up!!


AccessVandal via AccessMonster.com said:
Hi SG,

There is no Event called NotInList for ListBox. Did you mistook it for a
ComboBox?
 
Ad

Advertisements

A

AccessVandal via AccessMonster.com

Hi SG,

If it’s a comboBox, try to undo the control first before opening a form.
Because the combobox is bound and opening the next form causes the setfocus
property of the control to loose focus thereby inserting data into the
column/field into the table.

Private Sub itemcode_NotInList(NewData As String, Response As Integer)

If MsgBox("The Itemcode cannot be found enter now?", _
vbYesNo) = vbYes Then
Me.Undo ‘undo first before opening form.
DoCmd.OpenForm "enter new product details", , , , acFormAdd, acDialog,
NewData
Response = acDataErrAdded
Else
Me.itemcode.Undo
Response = acDataErrContinue
End If

End If

End Sub

If Me.Undo doesn’t work try “Me.itemcode.Undo†or try “Docmd.runcommand
acCmdUndoâ€.
 
Ad

Advertisements


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