473,467 Members | 2,399 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Problem opening subform when double click record from main form

13 New Member
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:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_DblClick(Cancel As Integer)
  2.   DoCmd.OpenForm "ClaimDetail", , , "[SSN] = " & Me!ImportSsN
  3.  
  4. 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.
Nov 16 '09 #1
3 3586
thayes5150
13 New Member
OK, Never mind - this was a stupid error, have to treat the SSN as a string, so code should be :
Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenForm "ClaimDetail", , , "[SSN] = '" & Me!ImportSsN & "'"
I hate dynamic sql...:)
Nov 16 '09 #2
NeoPa
32,556 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.
Nov 16 '09 #3
NeoPa
32,556 Recognized Expert Moderator MVP
I have moved your new question into its own, separate, thread (Continued Problems on Subforms).
Nov 16 '09 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

6
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...
2
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...
2
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...
3
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,...
4
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...
5
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...
9
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...
1
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...
4
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...
0
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,...
0
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...
0
jinu1996
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
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...
0
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...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...

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.