473,399 Members | 4,254 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Stop user adding record to subform

DD
Hi i have borrowed this code from Nothwind
used in the subform ProductID..it comes up with an error on RunCommand
acCmdUndo

Can anyone advise or give me a better way
DD

Private Sub Form_Error(DataErr As Integer, Response As Integer)

' Errors can occur here if the user has not already selected a
customer for
' this order on the main form. If there is an error and Orders!BillTo
is Null
' inform the user and cancel the entry made in the subform.
If DataErr > 0 Then
If IsNull(Me.Parent!CustomerID) Then
MsgBox "Select a Customer to bill to before entering order
details info."
RunCommand acCmdUndo
Me.Parent!CustomerID.SetFocus
Response = acDataErrContinue
Else
Response = acDataErrDisplay
End If
End If

End Sub
Nov 12 '05 #1
2 1507
DD wrote:
Hi i have borrowed this code from Nothwind
used in the subform ProductID..it comes up with an error on RunCommand
acCmdUndo

Can anyone advise or give me a better way
DD

Private Sub Form_Error(DataErr As Integer, Response As Integer)

' Errors can occur here if the user has not already selected a
customer for
' this order on the main form. If there is an error and Orders!BillTo
is Null
' inform the user and cancel the entry made in the subform.
If DataErr > 0 Then
If IsNull(Me.Parent!CustomerID) Then
MsgBox "Select a Customer to bill to before entering order
details info."
RunCommand acCmdUndo
Me.Parent!CustomerID.SetFocus
Response = acDataErrContinue
Else
Response = acDataErrDisplay
End If
End If

End Sub

Code like that I would put into BeforeInsert, e.g.

Sub Form_BeforeInsert(Cancel As Integer)
If IsNull(me.Parent!CustomerID) Then
Msgbox "Oi, User... No!"
Me.Parent!CustomerID.SetFocus
Cancel = True
End If
End Sub

--
But why is the Rum gone?
Nov 12 '05 #2
"Trevor Best" <nospam@localhost> wrote in message
news:40***********************@auth.uk.news.easyne t.net...
Sub Form_BeforeInsert(Cancel As Integer)
If IsNull(me.Parent!CustomerID) Then
Msgbox "Oi, User... No!"


LOL! We need more messages like that.

Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: CFW | last post by:
I have read as much as I could find here and in Tony's site as well - being directed there from here. I have a three user database with a BE .mdb (Access 2K) in a share on one PC and each user...
5
by: Galina | last post by:
Hello A have an application in MS Access 2000. It has a form (courses), which has a subform (course occurrences), which has a subform (occurrence learning aims). The Learning aims subform is...
1
by: Richard Hollenbeck | last post by:
I'm getting errors. Access is telling me that it can't add a record. I have a table of college courses and a linked table of groups of activities in that course as a linked table (one course to...
6
by: Robin S. | last post by:
**Eric and Salad - thank you both for the polite kick in the butt. I hope I've done a better job of explaining myself below. I am trying to produce a form to add products to a table (new...
2
by: brenda.stow | last post by:
error msg " An error occured while referencing the object. You tried to run a visual basic procedure that improperly references a property or method of an object" This msg occurs everytime I add a...
0
by: Richnep | last post by:
Hi all,. I have a small issue I would like to resolve with VBA. I have a form which it's fields are bound to a table. Within that form is a subform which is a subtable. Tables relationship...
1
by: rdsandy | last post by:
Hi, Im using Access 2003. I have a form, with two buttons and a list box. When a user selects an item in the list box, the user clicks on one of the buttons which opens up the selected record. ...
2
by: EManning | last post by:
I posted a question on 5/5/08 asking how to trap an error caused by multiple users trying to access the same patient. Here's what I posted: "Using A2003. I've got an FE with a main form with a...
4
by: bkberg05 | last post by:
Hi I have a form called Customer whose record source is a table called Customer. The primary key is Customer_ID. On that form, there's a subform called sub_Customer_Contact_Log. It's record...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.