By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,454 Members | 2,629 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,454 IT Pros & Developers. It's quick & easy.

VBA Problems within An access 2003 form/Subform

P: 6
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
Share this Question
Share on Google+
11 Replies


PEB
Expert 100+
P: 1,418
PEB
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
Expert 100+
P: 1,418
PEB
In module or in your form code as you want!
Nov 15 '06 #3

P: 6
OH
MY
GOD

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

<3
Nov 15 '06 #4

PEB
Expert 100+
P: 1,418
PEB
Happy to help you!
Nov 15 '06 #5

NeoPa
Expert Mod 15k+
P: 31,186
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
Expert 100+
P: 1,418
PEB
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
Expert Mod 15k+
P: 31,186
Very true PEB!
Very true!

PS galantries is as the French - spelling same - pronunciation a little different.
Nov 15 '06 #8

PEB
Expert 100+
P: 1,418
PEB
Hé Hé nothing new about my English :(

;)
Nov 15 '06 #9

MMcCarthy
Expert Mod 10K+
P: 14,534
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

P: 6
*Strokes PEB*
Nov 17 '06 #11

PEB
Expert 100+
P: 1,418
PEB
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

Post your reply

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