473,378 Members | 1,510 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Problem opening subform when double click record from main form

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 3580
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 Expert Mod 16PB
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 Expert Mod 16PB
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.