Member already exists problem

V

VitoK

Hello,
I'm having a problem with a database where I get the member already exists
issue that has been talked about in other posts. I have <REM> out the code
and it still gets me the error so its probably an issue with the sub naming,
but I am at my wits end with this. I have changed the name of the combo box,
Deleted the procedure and re-entered it again, made sure that it said events
procedure in the box, have done a search for similarly named subs and only
found the one that is giving me the error. My code is as follows, but like i
said i have disabled the code with just the click sub and it still gives me
the error so I don't think it is a coding problem.

Private Sub cmbOption12_Change()
Me.txtCost1.Enabled = True
Me.txtCost1.SetFocus
txtCost1.Text = DLookup("[Option Cost]", "tblOptions", "[OptionID]=" & Forms!
[frmNewCarSale]!cmbOption12)

txtCost2.Visible = True
cmbOption22.Visible = True
cost1 = txtCost1.Value
Me.txtTotalPackages.SetFocus
PremiumCost = cost1 + cost2 + cost3 + cost4 + cost5 + Cost6 + Cost7 + Cost8 +
Cost9 + Cost10
txtTotalPackages.Text = PremiumCost

Me.txtCost1.Enabled = False
End Sub

Any help would be greatly appreciated!
 
M

Marshall Barton

VitoK said:
I'm having a problem with a database where I get the member already exists
issue that has been talked about in other posts. I have <REM> out the code
and it still gets me the error so its probably an issue with the sub naming,
but I am at my wits end with this. I have changed the name of the combo box,
Deleted the procedure and re-entered it again, made sure that it said events
procedure in the box, have done a search for similarly named subs and only
found the one that is giving me the error. My code is as follows, but like i
said i have disabled the code with just the click sub and it still gives me
the error so I don't think it is a coding problem.

Private Sub cmbOption12_Change()
Me.txtCost1.Enabled = True
Me.txtCost1.SetFocus
txtCost1.Text = DLookup("[Option Cost]", "tblOptions", "[OptionID]=" & Forms!
[frmNewCarSale]!cmbOption12)

txtCost2.Visible = True
cmbOption22.Visible = True
cost1 = txtCost1.Value
Me.txtTotalPackages.SetFocus
PremiumCost = cost1 + cost2 + cost3 + cost4 + cost5 + Cost6 + Cost7 + Cost8 +
Cost9 + Cost10
txtTotalPackages.Text = PremiumCost

Me.txtCost1.Enabled = False
End Sub


I don't see anything that corresponds to that error message.
OTOH, there are several things wrong with the code:

1) Don't use the Change event for this kind of thing. It
fires for every keystroke, before the combo box has its new
value. Use the AfterUpdate event instead.

2) Don't use the .Text property when assigning a value to a
control. The .Text property is used for a completely
different purpose.

3) Don't use SetFocus unless you really want a different
control to be active (for user interaction).


I suspect that the error message is coming from somewhere
else in your code. Either a custom msgbox that you have in
some code that checks for a "member" that already exists or
you are trying to add a duplicate item to a collection
object.
 

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