473,811 Members | 2,565 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Getting to the chosen subform record

Hi,
Creating databases was never in my job description but I've become
increasingly involved in this area and now really enjoy it. I've not
had any formal VBA training but picked up lots of excellent ideas and
tips from this NG.

I'm currently looking for a neater way of going directly to a
particlar record in a subform. This is for a database that keeps track
of clients and their correspondence (letters). Clients and letters are
in two linked tables.

The most commonly used form is the ( frmLetterDetail ) which has all
the clients details. Within this form is the subform (frmSubDetail)
which holds all that individual client's letters in a single form
layout.

The users of the database need frequently to go directly to the
details of a particular letter for a particular client. At present the
users enter the letter reference ID number in to a text box and an
action button initiates a search identifies the relevant client
(PersonID) and puts both these numbers in to a hidden form where they
can be picked up by the code.

The code is as follows:-

Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmHidden"
DoCmd.OpenForm stDocName, , , stLinkCriteria

End If

Dim PersonID As Long
Dim TxtID As Long
Dim ID As Long

Dim frm As Form ' This selects the main form ie the form for
the client.

DoCmd.OpenForm "frmLetterDetai l", _
WhereCondition: ="PersonID = Forms!frmHidden .Form.TxtPerson ID"

' This now selects the line in the sub form which lists the
clients different letters

Set frm = Forms!FrmLetter Detail!FrmSubDe tail.Form
With frm.RecordsetCl one

.FindFirst "ID = " & Forms!frmHidden .TxtID
If .NoMatch Then
MsgBox "Not found"
Else
frm.Bookmark = .Bookmark
End If
End With
Set frm = Nothing

DoCmd.Close acForm, "frmHidden"

My query is....is there a way of doing this without using the hidden
form? Incidentally, the query behind the hidden form is:-
SELECT tblMain.ID, tblMain.PersonI D
FROM tblPersons RIGHT JOIN tblMain ON tblPersons.Pers onID =
tblMain.PersonI D
WHERE (((tblMain.ID)=[Forms]![FrmFront]![TxtGotoRefNo]));

Any advice would be much appreciated.

Mar 22 '08 #1
3 1332
I take it you have a main form bound to tblPersons (your clients), and a
subform bound to tblMain (your letters.)
Alan,

Thanks for getting back to me.

Yes, the above is 100% correct.
The unbound text box named TxtGotoRefNo is where the users can enter a
number that matches to the primary key of tblMain (ID. is actually on
another form called frnFront. This frmFront is the form that appears
when the DB opens and it is the main navigation/menu form where other
unbound text boxes permit different searches and various command
buttons bring up reports etc.

I have lots of free time on Easter Monday and will have a go with your
suggested code.

Neantime , many thanks.

Jim
Mar 23 '08 #2
Allen, my apologies for the misspelling earlier.

I had a go with the air code. I had to add DAO to the reference
library and then it got part way through but the debug window came up
with error 2455 on the line:-

If Me.Dirty then Me.Dirty = False

I re-read your post and thought that this problem might be due to the
TxtGotoRefNo unbound text box being on frmFront which is unbound.

Would this be correct?

Jim

Mar 24 '08 #3
If the message says that the form has no Dirty property, then it must be an
unbound form. If it is an unbound form, you can omit the line, because there
is no record to be saved.

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

<se**********@g mail.comwrote in message
news:8a******** *************** ***********@i12 g2000prf.google groups.com...
Allen, my apologies for the misspelling earlier.

I had a go with the air code. I had to add DAO to the reference
library and then it got part way through but the debug window came up
with error 2455 on the line:-

If Me.Dirty then Me.Dirty = False

I re-read your post and thought that this problem might be due to the
TxtGotoRefNo unbound text box being on frmFront which is unbound.

Would this be correct?

Jim
Mar 24 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
24892
by: Rey | last post by:
Howdy all. Appreciate your help with several problems I'm having: I'm trying to determine if the Visit subform (subformVisits) has a new record or been changed, i.e. dirty. The form that contains the subform is named Clients. I have this code in the Add Client btn: If Forms!Clients.subformVisits!VisitDirty = True Then MsgBox "Visit subform is dirty!"
0
1589
by: Josh C. | last post by:
Hello everyone. I'm a bit of an Access newbie, so please bear with me. Please go to http://www.dumoti.com/access/ to view the database - 536kb. I'll go straight into examples: In the form NIGO_ITEM, you'll notice a subform to the NIGO_REASONS table. It won't let any data be entered into this subform and it gives the error: You cannot add or change a record because a related record is required in table CUSTOMER_TABLE. (Error 3201) This...
25
10278
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...
1
3735
by: xmp333 | last post by:
Hi, I have a form that is designed as a data sheet view. Attached to this is a subform with some VB code. When the user clicks on a row, the subform should pop up and run the VB code which accesses the record corresponding to the row clicked. To get this row, I tried using Me.Parent.Bookmark. Unfortunately, this gets the "Current Record" which is set via the navigation
2
2108
by: allyn44 | last post by:
Hi--I have an unbound form that either edits an existing record or creates a new one and then refreshes a subform that views the record(s) chosen. What I would like to do from here is go to the chosen record after the code runs so we can edit filed in that record. I set focus to the subform and then refresh it--then I want to go to the record brought up from the sql string Thanks for any ideas Bob Stafford
1
2702
by: kkrizl | last post by:
I have a form that displays general information about an alarm permit location. There's a subform that shows detailed information about burglar alarms that have gone off at the location. When a new alarm is entered on the subform, I want to print a report that shows the general information and the alarms that were entered. The record source for the form is the Mailing List table (key is Alarm #). The record source for the subform is the...
5
2258
by: Thelma Lubkin | last post by:
I have a form/subform with the common one-to-many relationship. The form allows user to display records and move to other records via the selector, to add,delete, and edit them, with the related records displayed in the subform going along for the ride. The parent form's recordset has fields string integer COLORNAME CLASSSIZE and a few more that aren't relevant here.
1
1610
by: sparks | last post by:
I have a form/table with an autoid it is linked to a table/form with and ID as a 1 to many. Under this form/table I need another table with many records for each on of the many in the previous table. form1 form2 form3 table1 table2 table3 autoid -1-------------@ ID -1-----------------@- ID2 of course it won't allow this so I put in a second ID
4
3434
by: JHite | last post by:
I am using Access 2003 on Windows XP. This is a simple database that contains “tblStaffers” containing names of the office staffers, “tblProjects” containing names of the office projects, and “tblStatusReports” containing the “StafferID” (link to Staffer table), the “ProjectID” (link to Projects table), a “Date” field, and a “Notes” field. There is a main form, “frmStaffEntry,” with a subform, “frmStatusReports,” for a user to...
0
9730
marktang
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...
0
9605
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,...
0
10651
Oralloy
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...
1
10403
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10136
tracyyun
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...
1
7671
isladogs
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...
0
6893
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();...
0
5555
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3868
muto222
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.