Hi
I have a form/subform where a new record is created on the subform by a
button click.
After the new record is created, I then need to go directly and display
the new record in the subform.
My current code is:-
Private Sub cmdPanelInfoOnl y_Click()
On Error GoTo Err_cmdPanelInf oOnly_Click
Dim strSql As String
Dim dbs As Database
Dim rsEpis As Recordset
Dim intPat As Integer
Set dbs = CurrentDb()
strSql = "Select Max([Episode ID]) as MaxId from Episode;"
Set rsEpis = dbs.OpenRecords et(strSql)
[EpisID] = rsEpis.Fields(" MaxId").Value + 1
DoCmd.SetWarnin gs False
intPat = [Patient ID].Value
DoCmd.OpenQuery "qinsEpisodeFor PanelOnly" - Inserts the default
values in the new record
DoCmd.SetWarnin gs True
[Forms]![frmpatient].Form.Filter = "[Patient]![Patient ID] = " & intPat
[Forms]![frmpatient].Form.Requery
'This next bit works, but needs to be sped up!!!!!
Do Until [subfrmEpisode].Form![Patient ID] = [intPat]
DoCmd.GoToRecor d , , acNext
Loop
Do Until [subfrmEpisode].Form![Episode ID] = [EpisID]
subfrmEpisode.S etFocus
DoCmd.GoToRecor d , , acNext
Loop
Exit_cmdPanelIn foOnly_Click:
Exit Sub
Err_cmdPanelInf oOnly_Click:
MsgBox Err.Description
Resume Exit_cmdPanelIn foOnly_Click
End Sub
I cannot seem to find a more efficient way of navigating directly to
the new sub form record
Can anybody assist please
Thanks
Gary 4 1738
try:
Dim frmS As Form
[Episid] = DMax("MaxId", "Episode") + 1
CurrentDb.Execu te "qinsEpisodeFor PaelOnly"
Set frmS = Me.subfrmEpisod e.form
frmS.Requery
frmS.RecordsetC lone.FindFirst "[Patient id] = " & [Episid]
frmS.Bookmark = frmS.RecordsetC lone.Bookmark
The above is ALL the code you need.
What I don't see, or understand is how your qinsEpisodeForP anelOnly" knows
what record to work on?
--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada pl************* ****@msn.com
Gary, just out of interest, what's the maximum number of Patients you're
forseeably likely to want to store in the database? ga*********@nhs .net wrote:
>Hi
I have a form/subform where a new record is created on the subform by a button click.
After the new record is created, I then need to go directly and display the new record in the subform.
My current code is:-
Private Sub cmdPanelInfoOnl y_Click() On Error GoTo Err_cmdPanelInf oOnly_Click Dim strSql As String Dim dbs As Database Dim rsEpis As Recordset Dim intPat As Integer
Set dbs = CurrentDb()
strSql = "Select Max([Episode ID]) as MaxId from Episode;"
Set rsEpis = dbs.OpenRecords et(strSql) [EpisID] = rsEpis.Fields(" MaxId").Value + 1
DoCmd.SetWarni ngs False intPat = [Patient ID].Value DoCmd.OpenQuer y "qinsEpisodeFor PanelOnly" - Inserts the default values in the new record DoCmd.SetWarni ngs True
[Forms]![frmpatient].Form.Filter = "[Patient]![Patient ID] = " & intPat [Forms]![frmpatient].Form.Requery
'This next bit works, but needs to be sped up!!!!!
Do Until [subfrmEpisode].Form![Patient ID] = [intPat]
DoCmd.GoToRecor d , , acNext Loop
Do Until [subfrmEpisode].Form![Episode ID] = [EpisID]
subfrmEpisode.S etFocus
DoCmd.GoToRecor d , , acNext Loop
Exit_cmdPanelI nfoOnly_Click:
Exit Sub
Err_cmdPanelIn foOnly_Click:
MsgBox Err.Description
Resume Exit_cmdPanelIn foOnly_Click
End Sub
I cannot seem to find a more efficient way of navigating directly to the new sub form record Can anybody assist please
Thanks
Gary
--
Message posted via AccessMonster.c om http://www.accessmonster.com/Uwe/For...ccess/200610/1
Thats great, thanks
What I really want now is to set the focus to the newly added record on
the subform
Thanks
Gary
Albert D. Kallal wrote:
try:
Dim frmS As Form
[Episid] = DMax("MaxId", "Episode") + 1
CurrentDb.Execu te "qinsEpisodeFor PaelOnly"
Set frmS = Me.subfrmEpisod e.form
frmS.Requery
frmS.RecordsetC lone.FindFirst "[Patient id] = " & [Episid]
frmS.Bookmark = frmS.RecordsetC lone.Bookmark
The above is ALL the code you need.
What I don't see, or understand is how your qinsEpisodeForP anelOnly" knows
what record to work on?
--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada pl************* ****@msn.com
<ga*********@nh s.netwrote in message
news:11******** **************@ i3g2000cwc.goog legroups.com...
Thats great, thanks
What I really want now is to set the focus to the newly added record on
the subform
you have to do it in two steps
step 1 - set focus to sub-form control
step 2 - set focus to a field on the sub-form control
so,
me.subfrmEpisod e.setfocus
me.subfrmEpsiod e.form.NameOfFi eldOnForm.setfo cus
--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada pl************* ****@msn.com This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Neil |
last post by:
I have a very puzzling situation with a database. It's an Access 2000 mdb
with a SQL 7 back end, with forms bound using ODBC linked tables. At our
remote location (accessed via a T1 line) the time it took to go to a record
was very slow. The go to mechanism was a box that the user typed the index
value into a combo box, with very simple code attached:
with me.RecordsetClone
.FindFirst " = " & me.cboGoTo
If Not .NoMatch Then
Me.Bookmark...
|
by: Iain Miller |
last post by:
Struggling a bit here & would be grateful for any help.
I have a table which has a list of people in it. Each person has a unique ID
automatically allocated by Access but also belongs to one of 5 Groups - call
them A to E. I'd like to generate a further automatic reference number based
on something like Group/Unique ID so when I create a new record Access
creates the Unique ID & I then enter in the group and then Access combines
the two...
|
by: Skully Matjas |
last post by:
I am using the following code (created by the wizard) to
allow to bring my form to a particular entery. But when I
edit the entery (ex: put new information into a blank
cell), it puts that record onto the bottom of the list
(even though it keeps its record number).
Also, There are certin names that i click on the list, and
it will not bring it up, rather it brings to the first
record (no matter how many times i try going to that...
|
by: Steve Strik |
last post by:
My Problem:
I have created a database here at work that is exhibiting some very
strange behaviour.
Essentially the database is structured in a manner where one table is
a master record table (tbl_MainRegister) providing a unique identifier
for documents and a means for identifying the docuement type. There
are then 4 additional tables (tbl_Meetings, tbl_Documents,
tbl_Project, tbl_Correspondence) which store the document details.
|
by: Lyn |
last post by:
Hi,
I am working on a genealogy form. The only table (so far) lists everybody
in the family, one record per person. Each record has an autonum ID.
The parent form (frmMainForm) displays the data in each record, which
includes the ID of the father and the mother (who also have records in the
table). One record per form.
I have a Tab Control in the form, and in one of the tabs I have a subform
(sfmSiblings) in which I wish to list...
| |
by: Zlatko Matiæ |
last post by:
There is a form (single form) and a combobox. I want that current record of
the form is adjusted according to selected value in the combobox. Cuurrent
record should be the same as the value in the combobox.
What is the solution?
Thank you in advance.
|
by: swingingming |
last post by:
Hi, in the NorthWind sample database, when clicking on the next
navigation button on the new order record with nothing on the subform
(order details), we got an order with nothing ordered. How can we
prevent this from happening?
Thanks.
ming
|
by: ortaias |
last post by:
I have a form which calls up a second form for purposes of data entry.
When closing the data entry form and returning to the main form, things
don't work as expected.
When I return to the main form, I trigger the on acitvate event to run
a macro. I can use the Dlookup function to update my fields, which is
OK. However, I intitially tried to use the Repaint Object command to
repaint the form. That did not work. Though I solved the...
|
by: kev |
last post by:
Hi all,
I have created a database for equipments. I have a form to register the
equipment meaning filling in all the particulars (ID, serial, type,
location etc). I have two buttons at the end of the form which is
submit and cancel. After i have clicked submit, the information is
stored directly into my corresponding database table. My problem here
is i need to retrieve back the information submitted to display all the
data that the...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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 then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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 we have to send another system
| |
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |