I have an Access 2003 database used to research unemployment claims. The main form contains a subform in datasheet view listing the employee claim records, including employee Social security number. I would like them to be able to double Click a record in this datasheet and have it open a subform, populated from a Query that is passed the SSN from the recordset that was clicked. I have included the following code in the vba: - Private Sub Form_DblClick(Cancel As Integer)
-
DoCmd.OpenForm "ClaimDetail", , , "[SSN] = " & Me!ImportSsN
-
-
End Sub
The form does open on double click, if I look at the for properties, the filter is set to the correct SSN, but the records will not display. I know I am missing something obvious, please help.
3 3608
OK, Never mind - this was a stupid error, have to treat the SSN as a string, so code should be : - DoCmd.OpenForm "ClaimDetail", , , "[SSN] = '" & Me!ImportSsN & "'"
I hate dynamic sql...:)
NeoPa 32,571
Recognized Expert Moderator MVP
One of the most popular (frequently occurring rather than best liked) problems we get is with SQL strings being manipulated in VBA code.
The reason this is so difficult is that all the work is being done at a level of redirection. What I mean by this is that the coder is never working directly with the SQL itself, but rather with code which in turn, is relied on to produce the SQL that they are envisaging is required. It's rather similar to the problems coders have historically had dealing with pointers.
Anyway, a technique I often suggest to coders struggling with this (at any level. This happens to experienced coders too.) is to use either the MsgBox() function, or Debug.Print into the Immediate Pane of the debugger window, to display the value of the SQL in the string before using it (That's assuming you're not good with debugging generally. Personally I would trace to the line, then display the value prior to allowing execution of the string - See Debugging in VBA). It's really much easier to appreciate what a SQL string is meant to do, and where there may be problems, when you can see it in its entirety, and in its true form, rather than as the code is about to create it.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: William Bradley |
last post by:
I have a production table and its accompanying form. There can be up to ten
ingredients in what is produced.
The ingredients are obtained from the incoming goods table which supplies
the two parameters that I use, "Name" and "CatlogNo".
This production table needs to contain each ingredient by name and catalogue
number. With help from this list I was able to set up a combo box that
allowed me to select a particular ingredient, and when...
|
by: CSDunn |
last post by:
Hello,
In an Access 2003 ADP Subform, I am trying to set the BackGround color
of three textbox fields (LSScore, RScore, WScore) in the current
record of the subform to zero (black) if the value of a bound checkbox
field (Spanish) on the current record is True, and to 16777164 if the
value of the bound checkbox field is False.
The Subform's Name property is 'frmMainScores'. The Source Object
Property of the Subform is 'frmMainSubScores'....
|
by: Lyn |
last post by:
Hi,
I am working on a genealogy project in which I have two tables:
Person -- one record for each person in the family. Each record has a
unique Autonum field (IDPerson).
Partnerships -- one record for each marriage. Each record has a unique
Autonum field (ID), and also contains two fields IDPartnerMale and
IDPartnerFemale. Both of the latter fields match records in the Person
table via IDPerson.
|
by: Diana Gard |
last post by:
Perhaps this is a design flaw, please let me know.
I'm using Access 2000. I have a form with a tab control and 5
subforms within those tabs. The forms match with the tables: Client
main, Intake, Financial, Fees, Payments, Bills, Bill Line Items. The
design works thusly - Client Main relates to Intake. Intake relates to
financial. Financial relates Fees, Payments and Bills. Bills relates
to Bill Line Items.
On the form, I use the...
|
by: Dave Boyd |
last post by:
Hi,
I have two very similar forms each with a subform. The main form gets
a few fields from the user and passes this back to a query that the
subform is bound to. The requery is done when the user enters the
last qualifying field on the main form.
In one case this works fine, the subform shows the data the user wants
to update -- which means showing all the data put in previously (ie
showing this via the requery and the continuous...
| |
by: lorirobn |
last post by:
Hi All,
I have a listbox on a main form. When user double-clicks an item in
the list box, I move the selected values to a subform at the bottom of
the form. List box is not multiselect, and subform is continuous form.
This is a work-in-progress, but seems to be working ok.
On my subform I have a sequence number field. When user selects from
the listbox, and the values are moved to the subform, I need to
calculate the sequence...
|
by: Ecohouse |
last post by:
I have a main form with two subforms. The first subform has the child
link to the main form identity key.
subform1 - Master Field: SK
Child Field: TrainingMasterSK
The second subform has a master-child link to the first subform.
subform2 - Master Field: subTrainingModule.Form!TrainingModuleTopicSK
Child Field: TrainingModuleTopicSK
|
by: Coll |
last post by:
I have a form with a subform on it. On my main form, you select an
employee id number and the top portion of form fills in with data, and
the bottom portion of the form,which is a subform, lists existing
records there are for that employee (one to many relationship). How
can I set up my main form, so the user can select one of the records
on the subform and retain that recordid number for use in opening a
new form and displaying the that...
|
by: Savita23 |
last post by:
Hi,
I have a subform in datasheet layout embedded in the main form.I want to invoke a procedure on the double click of each record in the subform.Is there a away by which I can fire the double click event of Detail section of the subform from the main form?I can't find this event.
As of now,I am invoking the procedure in the Form_DblClick event of the subform.But this invokes the procedure when I double click on any part of the subform.I...
|
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: 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,...
|
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: 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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |