Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Update Error Message on my Form

Status
Not open for further replies.

thembela

Technical User
Jun 4, 2005
29
ZA
Hi All,

tHERE'S a piece of VB code to synchronise my form to the value in the Combo Box. The VB code is attached to the After Update event of the Combo Box. And sometimes when I select a value on my Combo Box, I get the ERROR message. I suspect there’s something wrong with my code. I can’t seem to figure it out because my knowledge in VB is very limited and basic. What could be wrong???

The error message says: UPDATE OR CANCELUPDATE WITHOUT ADDNEW OR EDIT.


hERE's the VB code:

Private Sub Benton_AfterUpdate()
Dim rs As Recordset
Set rs = Me.RecordsetClone
rs.FindFirst "[BRK_ENTITY_NO] = " & [Forms]![frmbroker]![Benton]
If (DCount("*", "[Broker Information]", "[BRK_ENTITY_NO] = [forms]![frmBroker]![Benton]") = 0) Then
MsgBox " OOPS!!!THE VALUE ENTERED," & [Benton] & " IS NOT A VALID BROKER NUMBER"
Me.Benton.Value = Null
Else
Me.Bookmark = rs.Bookmark
End If
Set rs = Nothing
End Sub




 
You may replace this:
If (DCount("*", "[Broker Information]", "[BRK_ENTITY_NO] = [forms]![frmBroker]![Benton]") = 0) Then
with this:
If rs.NoMatch Then

BTW, which line is highlighted when in debug mode ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Hi thembela,
If you want to keep the combox sync to current record, you can add this to the OnCurrentEvent:
Private Sub Form_Current()
YourCombo = YourVariableID
End Sub

Pampers - [afro]

you're neven too young to learn
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top