473,586 Members | 2,566 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

VBA Problems within An access 2003 form/Subform

6 New Member
Hi,

Im making a db for my company in Access 2003 usin xp sp2. Ive created an orders form that has a subform in it. The Order form (parent(is linked to a Orders Qry)) and the Orders Subform (Child(is linked to Order Details Extended Qry).

This works similar to the Orders form in Northwind, ok ok its pretty much identitcal What happens is i select a client in the main form by selecting the company name and that pulls up their details. In the Subform im supposed to select a product and enter the quantity being ordered. However when i select a 2nd product i get the following vba error:

Compile error: Sub or Function not defined..

Heres the code:

Private Sub Form_BeforeUpda te(Cancel As Integer)
' If Orders Subform is opened as a standalone form, display a message
' and undo changes made to the ProductName text box. (The IsLoaded function
' finds a form in the Forms collection when it's opened as a standalone
' form, but not when it's opened as a subform on a main form.)

Dim strMsg As String, strTitle As String
Dim intStyle As Integer

If IsLoaded("Order s Subform") Then
strMsg = "You can't add or edit a record when you open Orders Subform as a standalone form."
intStyle = vbOKOnly
strTitle = "Can't Add or Change Record"
MsgBox strMsg, intStyle, strTitle
Me.Undo
End If

End Sub

the IsLoaded part gets highlighted.

Now ive bought 3 books on Access, and using VBA in access, but i havent been able to find a solution yet :(
Nov 15 '06 #1
11 5844
PEB
1,418 Recognized Expert Top Contributor
OK add
Expand|Select|Wrap|Line Numbers
  1. Function IsLoaded(Forma) As Integer
  2.     IsLoaded = (SysCmd(acSysCmdGetObjectState, acForm, Forma) And acObjStateOpen) <> False
  3. End Function
  4.  
  5.  
Hi,

Im making a db for my company in Access 2003 usin xp sp2. Ive created an orders form that has a subform in it. The Order form (parent(is linked to a Orders Qry)) and the Orders Subform (Child(is linked to Order Details Extended Qry).

This works similar to the Orders form in Northwind, ok ok its pretty much identitcal What happens is i select a client in the main form by selecting the company name and that pulls up their details. In the Subform im supposed to select a product and enter the quantity being ordered. However when i select a 2nd product i get the following vba error:

Compile error: Sub or Function not defined..

Heres the code:

Private Sub Form_BeforeUpda te(Cancel As Integer)
' If Orders Subform is opened as a standalone form, display a message
' and undo changes made to the ProductName text box. (The IsLoaded function
' finds a form in the Forms collection when it's opened as a standalone
' form, but not when it's opened as a subform on a main form.)

Dim strMsg As String, strTitle As String
Dim intStyle As Integer

If IsLoaded("Order s Subform") Then
strMsg = "You can't add or edit a record when you open Orders Subform as a standalone form."
intStyle = vbOKOnly
strTitle = "Can't Add or Change Record"
MsgBox strMsg, intStyle, strTitle
Me.Undo
End If

End Sub

the IsLoaded part gets highlighted.

Now ive bought 3 books on Access, and using VBA in access, but i havent been able to find a solution yet :(
Nov 15 '06 #2
PEB
1,418 Recognized Expert Top Contributor
In module or in your form code as you want!
Nov 15 '06 #3
BobBanks
6 New Member
OH
MY
GOD

I LOVE YOU :D you know know how long that was frustrating me for!!!!

<3
Nov 15 '06 #4
PEB
1,418 Recognized Expert Top Contributor
Happy to help you!
Nov 15 '06 #5
NeoPa
32,566 Recognized Expert Moderator MVP
Hey PEB.
I hate to worry you, but with a name like BobBanks, I'm guessing this is no girl.
Very friendly :S

J/K
-Adrian.

PS. I guess we can consider this post answered ;)
Nov 15 '06 #6
PEB
1,418 Recognized Expert Top Contributor
Hi hi hi

In a lot of cases u can understand here is there a man or a woman in front!

But in this case watching the name we can be sure that this is a man!

I've some stories here!

In the begining i thought that under mmcarthy participate a man, but in fact is Mary!

Not very often to see a woman in such a technical forum man :)

Once seeing the name it seemed that it's a woman but observing the forum there was a man! hi hi hi

So Adrian take care, with the galancies here it's dangerous! ;)
Nov 15 '06 #7
NeoPa
32,566 Recognized Expert Moderator MVP
Very true PEB!
Very true!

PS galantries is as the French - spelling same - pronunciation a little different.
Nov 15 '06 #8
PEB
1,418 Recognized Expert Top Contributor
Hé Hé nothing new about my English :(

;)
Nov 15 '06 #9
MMcCarthy
14,534 Recognized Expert Moderator MVP
Hé Hé nothing new about my English :(

;)
What do you mean you thought I was a MAN!!!



I'm shocked ...



Mary
Nov 16 '06 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

5
10611
by: Ellen Manning | last post by:
Using A2K. I need the syntax to set the recordsource for a subform within a subform. The "main" subform's recordsource changes based on user input. I need to change the recordsource on the subform within that. What is the correct syntax? Thanks.
0
2404
by: Sabine Oebbecke | last post by:
Hi Experts! I have several forms and reports where controls get their values with 'Forms!MainForm!Control' or 'Forms!MainForm!Subform!Control' resp 'Forms!MainForm!Subform.Form!Control' which works without any problem in Acc97, 2000 and 2002, but now in Access 2003 there seem to be a problem with this. A user is working with my app, and...
2
1533
by: Jan Szymczuk | last post by:
Thanks again guys, for your recent assistance. Now as you were so kind to assist the first time (the solution was so simple and elegant) I was wondering if you could assist with another couple of problems I am faced with. Problem 1 I have a memo field called NOTES in my database and I have constructed various queries so the user can search...
10
2393
by: BBFrost | last post by:
We just recently moved one of our major c# apps from VS Net 2002 to VS Net 2003. At first things were looking ok, now problems are starting to appear. So far ... (1) ComboBox.SelectedValue = db_value; If the db_value was not included in the ComboBox value list the ComboBox.SelectedIndex used to return -1, Now the very same code is
3
2745
by: google | last post by:
I'm developing an application for use within my company in Access 2003. I'm new to '03, the application I did for my former employer was in '97. The two applications have similar functionality (we're sales offices, and I'm doing things such as associate directories, commission calculations, order tracking, etc.). 2003 seems to have a few...
2
4394
by: Wayne | last post by:
I'm experiencing the following intermittent problem with Access 2003 (Access 2000 file format) under Vista. Sometimes when I close a database by closing the database window I get the following unhelpful generic message: "Microsoft Access has stopped working. A problem caused the program to stop working correctly. Please close the program. ...
5
2775
Scott Price
by: Scott Price | last post by:
Hello, I'm running Access 2003 trying to filter a subform with approximately 15 records per year per the main record contained on the parent form. The filter works fine if the subform is opened independently, and right-clicking on the subform after opening the main form, and choosing filter by selection also works. The problem is getting the...
4
6041
by: Harlequin | last post by:
I have a question concerning the need to trigger events within a "child" subform which is itself enbedded within a master "parent" form and which is accessible via a tab in the parent form. Becuase this is all very difficult to explain in words, please bear with me as I endevour to explain what it is I am trying to do. It would be helpful if I...
2
1661
by: franc sutherland | last post by:
Hi, I am using Access 2003. I am having a problem with a pair of combo boxes. I want the second one (cbo_service) to have it's row source limited by the value I select in the first one (cbo_supplier). I have added the criteria in the query for cbo_service that it is limited by the value selected in cbo_supplier, using the full location...
0
7839
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8202
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7959
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8216
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6614
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3837
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3865
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1449
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1180
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.