473,473 Members | 1,832 Online
Bytes | Software Development & Data Engineering Community
Create 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_BeforeUpdate(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("Orders 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 5831
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_BeforeUpdate(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("Orders 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,556 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,556 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
BobBanks
6 New Member
*Strokes PEB*
Nov 17 '06 #11
PEB
1,418 Recognized Expert Top Contributor
Hein .... in fact i was a young member not well oriented...

Sometimes we do a faults like this one :)

all human is appropriate for me also ;)

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



I'm shocked ...



Mary
Nov 18 '06 #12

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

Similar topics

5
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...
0
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...
2
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...
10
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) ...
3
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...
2
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...
5
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...
4
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...
2
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...
0
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...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
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...
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
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.