A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Multiple Instances problem



 
 
Thread Tools Display Modes
  #1  
Old July 16th, 2004, 04:09 PM
Jordan
external usenet poster
 
Posts: n/a
Default Multiple Instances problem

My main form (called Patient Records) is a tab form with
different sub forms on each tab page. My problem is that
when I open the form using the a button with the code
below, none of my calculations that reference fields on
these different tab pages works! It gives a #Name?
error. Any new instances I open from the button on the
main form have the same problem. However, when I open
the form independent of this code, there is no problem,
nor is there any problem with the added instances. This
of course leads me to believe that my code to open the
initial instance has problems. How it works is that I
have a button on my Main Menu to open the search dialog
box (called SearchBox). After searching, the results are
displayed in a continuous subform with the button
containing this code as part of each of the continuous
records. Anybody have any ideas on what the problem
could be?

Private Sub ViewRecord_Click()

Dim frm As Form
Dim lngHwnd As Long
Dim blnFound As Boolean

If IsNumeric(Forms.searchbox.CalledFrom) Then
'Find the calling form
lngHwnd = Forms.searchbox.CalledFrom
For Each frm In Forms
If frm.hWnd = lngHwnd Then

'Find this record in that form.
With frm.RecordsetClone
.FindFirst "[ID]=" & Me![ID]
If Not .NoMatch Then
frm.Bookmark = .Bookmark
blnFound = True
End If
End With
Exit For

End If
Next
Else
Set frm = New [Form_Patient Records]
frm.Visible = True
frm.Caption = "Patient Records: " & Now()

'Append it to collection
clnPatientRecords.Add Item:=frm, Key:=CStr
(frm.hWnd)

'Find this record in that form.
With frm.RecordsetClone
.FindFirst "[ID]=" & Me![ID]
If Not .NoMatch Then
frm.Bookmark = .Bookmark
blnFound = True
End If
End With

DoCmd.Close acForm, "SearchBox"
End If

If blnFound Then
'Focus on the calling form, and close this one.
frm.SetFocus
Set frm = Nothing
DoCmd.Close acForm, "SearchBox"
Else
Beep
End If

Set frm = Nothing

End Sub
  #2  
Old July 19th, 2004, 03:21 PM
Jordan
external usenet poster
 
Posts: n/a
Default Multiple Instances problem

No takers on this one? If anyone can help me figure this
out, I'd really appreciate it. Thanks.

-----Original Message-----
My main form (called Patient Records) is a tab form with
different sub forms on each tab page. My problem is

that
when I open the form using the a button with the code
below, none of my calculations that reference fields on
these different tab pages works! It gives a #Name?
error. Any new instances I open from the button on the
main form have the same problem. However, when I open
the form independent of this code, there is no problem,
nor is there any problem with the added instances. This
of course leads me to believe that my code to open the
initial instance has problems. How it works is that I
have a button on my Main Menu to open the search dialog
box (called SearchBox). After searching, the results

are
displayed in a continuous subform with the button
containing this code as part of each of the continuous
records. Anybody have any ideas on what the problem
could be?

Private Sub ViewRecord_Click()

Dim frm As Form
Dim lngHwnd As Long
Dim blnFound As Boolean

If IsNumeric(Forms.searchbox.CalledFrom) Then
'Find the calling form
lngHwnd = Forms.searchbox.CalledFrom
For Each frm In Forms
If frm.hWnd = lngHwnd Then

'Find this record in that form.
With frm.RecordsetClone
.FindFirst "[ID]=" & Me![ID]
If Not .NoMatch Then
frm.Bookmark = .Bookmark
blnFound = True
End If
End With
Exit For

End If
Next
Else
Set frm = New [Form_Patient Records]
frm.Visible = True
frm.Caption = "Patient Records: " & Now()

'Append it to collection
clnPatientRecords.Add Item:=frm, Key:=CStr
(frm.hWnd)

'Find this record in that form.
With frm.RecordsetClone
.FindFirst "[ID]=" & Me![ID]
If Not .NoMatch Then
frm.Bookmark = .Bookmark
blnFound = True
End If
End With

DoCmd.Close acForm, "SearchBox"
End If

If blnFound Then
'Focus on the calling form, and close this one.
frm.SetFocus
Set frm = Nothing
DoCmd.Close acForm, "SearchBox"
Else
Beep
End If

Set frm = Nothing

End Sub
.

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Productkey problem when installing office 2003 on network Stefan Schreurs Setup, Installing & Configuration 1 June 1st, 2004 11:16 PM
word error mac General Discussions 1 May 6th, 2004 08:14 AM
multiple instances Aaron Worksheet Functions 2 March 3rd, 2004 07:36 PM
Multiple Conditions and Multiple Solutions Frank Kabel Worksheet Functions 0 February 4th, 2004 09:22 PM
Multiple Instances of Excel opening Carolyn Setting up and Configuration 1 September 19th, 2003 02:13 AM


All times are GMT +1. The time now is 05:49 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.