UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
2 Pages V  1 2 >  (Go to first unread post)
   Reply to this topicStart new topic
> By-Pass a Procedure    
 
   
quest4
post Oct 19 2004, 07:35 AM
Post#1



Posts: 1,884
Joined: 4-September 03
From: Cleveland, OH


Good morning. A quick question, I would like to open a form from another form, but I need to by-pass the new form's OnOpen event. Can this be done? Thank you in advance for any opeions offered here. shrug.gif
Go to the top of the page
 
khaos
post Oct 19 2004, 07:37 AM
Post#2


Retired Moderator
Posts: 8,589
Joined: 19-December 02
From: Lansing, MI


You could use the open args parameter in the on open call. Use that in the on open of the 2nd form and with an if loop bypass the code if needed.
TH
Ken
Go to the top of the page
 
quest4
post Oct 19 2004, 07:46 AM
Post#3



Posts: 1,884
Joined: 4-September 03
From: Cleveland, OH


Thank you for the response, Ken. You wouldn't happen to have a quick example would you. Sounds interesting, with possiblities. My form's OnOpen event creates new records or calls entered existing ones and I would like to get around it or by-pass it, so I could open it from a search form, in its' OnClick event. Thank you again for the help.
Go to the top of the page
 
dannyseager
post Oct 19 2004, 07:50 AM
Post#4


UtterAccess VIP
Posts: 13,031
Joined: 2-March 04
From: Leicester, UK


I assume you want to do this because newform is usually opened from form1 but in some cases it's loaded from form2 but in the on open of the newform it refers to form1 and you want these ignored if it's opened from form2?
You could alter the on open procedure to check to see if form1 is open so if it's not it ignores the code it needs to..
If CurrentProject.AllForms("form1").IsLoaded = True Then
normal open code assuming that form 1 is loaded
else
new code if it's opened from form 2
end if
Go to the top of the page
 
khaos
post Oct 19 2004, 08:03 AM
Post#5


Retired Moderator
Posts: 8,589
Joined: 19-December 02
From: Lansing, MI


Just look up open args in the vba help. Great example there.
TH
Ken
Go to the top of the page
 
quest4
post Oct 19 2004, 08:39 AM
Post#6



Posts: 1,884
Joined: 4-September 03
From: Cleveland, OH


Thank you both for the responses. Danny, I am trying to open the main form from one of two different search forms, but I don't want the main forms OnOpen event to run, because the procedure will ask if this is a new record yes/no and from there the whole OnOpen procedure kicks in. I am not even sure if the example would work that way. Ken, I will definately look into vb Help, what a surprise, Help actually helping for a change. Thank you both again for the help.
Go to the top of the page
 
khaos
post Oct 19 2004, 08:45 AM
Post#7


Retired Moderator
Posts: 8,589
Joined: 19-December 02
From: Lansing, MI


You're welcome, glad to help. The vba help has great info it's just not easy to find sometimes. I have better luck putting my cursor on a keyword and hitting f1, this returns different and better results than typing it into the help search box.
en
Go to the top of the page
 
quest4
post Oct 19 2004, 08:49 AM
Post#8



Posts: 1,884
Joined: 4-September 03
From: Cleveland, OH


Thank you for the tip I will have to try it. I am going to start to build a procedure and see if it will work. Thanks.
Go to the top of the page
 
quest4
post Oct 19 2004, 09:25 AM
Post#9



Posts: 1,884
Joined: 4-September 03
From: Cleveland, OH


I have been trying a few things now and I can not get by the OnOpen event of the main form. This was what I have been playing with:
Dim stDocName As String
'Dim stLinkCriteria As String
stDocName = "frmQualityControlAction"
'stLinkCriteria = "[QCANo]=" & Me![QCANo]
DoCmd.OpenForm stDocName, , , stLinkCriteria
If SysCmd(acSysCmdGetObjectState, ACForm, "frmQualityControlAction") Then
Forms("frmQualityControlAction")("QCANo").Value = Me("QCANo").Value
DoCmd.Close ACForm, "frmPartNoLookUp"
End If
The If SysCmd works great inside the main form, I am using it as a find QCANo and load it into the main form. The trick is to Open the main form and by-passing the OnOpen event. Right now, The main form is opening, but the yes/no of the OnOpen procedure is poping up. Is there any modification I can do to this to get around OnOpen? Thank you again in advance.
Go to the top of the page
 
quest4
post Oct 19 2004, 10:22 AM
Post#10



Posts: 1,884
Joined: 4-September 03
From: Cleveland, OH


I made a change to this but it is erroring out:
If Not IsNull(Forms!frmQualityControlAction.OpenArgs) Then
Dim strQCA As String
strQCA = Forms!frmQualityControlAction.OpenArgs
Dim rs As Recordset
Set rs = Forms!frmQualityControlActionRecordsetClone
rs.FindFirst "QCANo = '" & strQCA & "'"
If Not rs.NoMatch Then
Me.Bookmark = rs.Bookmark
End If
End If
The error is: Method or Data Member not Found
The debugger hi-lites the FindFirst. Any suggestions? Thanks. confused.gif confused.gif
Go to the top of the page
 
khaos
post Oct 19 2004, 01:17 PM
Post#11


Retired Moderator
Posts: 8,589
Joined: 19-December 02
From: Lansing, MI


Change this
im rs As Recordset
to
Dim rs As ADODB.Recordset
and tell me what you get.
Go to the top of the page
 
quest4
post Oct 19 2004, 01:21 PM
Post#12



Posts: 1,884
Joined: 4-September 03
From: Cleveland, OH


Same thing same error message.
Go to the top of the page
 
quest4
post Oct 19 2004, 01:35 PM
Post#13



Posts: 1,884
Joined: 4-September 03
From: Cleveland, OH


This may make things easier. It is striped but everything opens.
Go to the top of the page
 
khaos
post Oct 19 2004, 01:46 PM
Post#14


Retired Moderator
Posts: 8,589
Joined: 19-December 02
From: Lansing, MI


Which form do I need to look at?
Go to the top of the page
 
quest4
post Oct 19 2004, 01:51 PM
Post#15



Posts: 1,884
Joined: 4-September 03
From: Cleveland, OH


Ops, sorry about that. I am working on the OnClick event of the frmPartNoQCALookUp, the OnClick is in the subform, fsubPartNoQCALookup. When one of the QCANo numbers is click the other form,frmQualityControlAction, should open and theat record should be in it. Am it being clear enough? Thank you again for the help.
Go to the top of the page
 
khaos
post Oct 19 2004, 03:23 PM
Post#16


Retired Moderator
Posts: 8,589
Joined: 19-December 02
From: Lansing, MI


This code should fire from the subform "fsubPartNoQCALookup"
tDocName = "frmQualityControlAction"
stLinkCriteria = "[QCANo]=" & Me![QCANo]
DoCmd.OpenForm stDocName, , , stLinkCriteria
this code should be in the on open event of form "frmQualityControlAction"
If Not IsNull(me.OpenArgs) Then
Dim strQCA As String
strQCA = me.OpenArgs
Dim rs As ADODB.Recordset
Set rs = Forms!frmQualityControlActionRecordsetClone
rs.FindFirst "QCANo = '" & strQCA & "'"
If Not rs.NoMatch Then
Me.Bookmark = rs.Bookmark
End If
End If
Can't test it as I'm missing some references you have.
HTH
Ken
Go to the top of the page
 
quest4
post Oct 19 2004, 03:55 PM
Post#17



Posts: 1,884
Joined: 4-September 03
From: Cleveland, OH


Thank you so very much Ken. I see I had my code in the wrong place. One major question, will this interfer with the OnOpen event that is already in the form, frmQualityControlAction? That is what is opening the form normally, and that is the main form in the dbase. I would hate to scramble that up. Thank you again for all of the help, I will try this in the morning.
Go to the top of the page
 
khaos
post Oct 20 2004, 06:50 AM
Post#18


Retired Moderator
Posts: 8,589
Joined: 19-December 02
From: Lansing, MI


Just do this
If Not IsNull(me.OpenArgs) Then
Dim strQCA As String
strQCA = me.OpenArgs
Dim rs As ADODB.Recordset
Set rs = Forms!frmQualityControlActionRecordsetClone
rs.FindFirst "QCANo = '" & strQCA & "'"
If Not rs.NoMatch Then
Me.Bookmark = rs.Bookmark
End If
else
'code originally in the on open event
End If
HTH
Ken
Go to the top of the page
 
quest4
post Oct 20 2004, 07:31 AM
Post#19



Posts: 1,884
Joined: 4-September 03
From: Cleveland, OH


Good morning, Ken. Same error, Method or Data member not Found. Then the debugger pops up its' ugly head and hi-lites the word FindFirst. Same as before. I did try MoveFirst, to see what would happen, it error out also, but different error. Dumb question time, isn't FindFirst DAO? Or does it work in both? Also, I did change it to DAO, But I got the YES/NO pop-up, no by-pass. Thank you again for all of your help and time. shrug.gif
Edited by: quest4 on Wed Oct 20 8:38:12 EDT 2004.
Go to the top of the page
 
khaos
post Oct 20 2004, 07:36 AM
Post#20


Retired Moderator
Posts: 8,589
Joined: 19-December 02
From: Lansing, MI


Change this
im rs As ADODB.Recordset
to
Dim rs As Object
That may clear it up right away.
Ken
Go to the top of the page
 
2 Pages V  1 2 >


Custom Search


RSSSearch   Top   Lo-Fi    19th July 2019 - 01:41 AM