473,399 Members | 2,159 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,399 software developers and data experts.

DoCmd.OpenForm problems

20
Hi,

I am using Access 2003. I have a list box on a form which has 6 columns in it, with data taken from a table. I have an unbound text box which holds the ID number for the selected item in the list box. I have a command button which I want to use to open another form on that record. At the moment it opens the other form but only to the first record. The other form has its recordset set to the same table as what the list box displays certain data for. Basically, the list box displays certain more important data, and the user clicks on the item to be viewed and then the next form displays all the data.

I have used this code to try and open the form to the correct record with no luck:

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmbSelected_Click()
  2.  
  3. Dim stLinkCriteria As String
  4.  
  5.     stLinkCriteria = "[RiskEstimateID] = '" & Me.txtLstRPET & "'"
  6.  
  7.     DoCmd.OpenForm "RiskEstimating", acNormal, , stLinkCriteria, , acNormal
  8.  
  9. End Sub
  10.  
I have also tried to open the form with OpenArgs with no luck, like this:

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmbSelected_Click()
  2.  
  3.     DoCmd.OpenForm "RiskEstimating", acNormal, , , , acNormal, Me.txtLstRPET
  4.  
  5. End Sub
  6.  
  7.  
  8. Private Sub Form_Open(Cancel As Integer)
  9.  
  10.     Me.RiskEstimateID = Me.OpenArgs
  11.  
  12. End Sub
  13.  
I have tried debugging and going through the code and in theory it should work, but it just doesn't. If say the ID number is 4 for the selected item in the list box, then the value in txtLstRPET goes to 4. For the stLinkCriteria it says "[RiskEstimateID] = '4', but the 4th record doesn't display in the form when opened.

Many thanks in advance,

Andrew
Mar 10 '08 #1
1 2012
rdsandy
20
I sorted this out now. I removed the record source completely from the 2nd form being opened (which was the table for the form), ran the program, then put the record source back in, closed and reopened the database and ran the program again and it worked. I think Access got lost on what variables it had when I had errors trying to solve it.
Mar 12 '08 #2

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

Similar topics

6
by: beowulfs | last post by:
Here's what I've got: I've got a form with combo boxes. you can select already existing company names or type in new ones. if you type in a new one, it prompts you to double click the combo...
3
by: Lyn | last post by:
Hi, I have a Search input form which collects from the user a person's name. I am using LIKE with a "%" suffix in the SQL so that the user does not have to type in the full name. When they hit...
15
by: Thelma Lubkin | last post by:
formA determines some_where and some_value and issues docmd.close ,Me docmd.openform "formB", , ,some_where, , ,some_value formB receives the correct some_where and some_value After...
8
by: John Welch | last post by:
I have a command button with the following code: DoCmd.OpenForm "frmSearchAssignments", , , "SearchAssignmentID = 1" (SearchAssignmentID is the PK, auto number) When it runs, the form opens but...
2
by: Mike | last post by:
I am trying to open a search results form based on the input from a prompt form. I am using the following code: --- Begin Code --- Private Sub btnSearch_Click() 'Dim Variable and assign data...
9
by: keliie | last post by:
Hello (from Access novice), I'm building a switchboard form (using a Treeview object). The treeview is populated by two tables (tblSwitchboardParent and tblSwitchboardChild). Within...
2
by: rturpyn | last post by:
I want to simply open a form, I don't want to limit the records returned. I'm using the code.... DoCmd.OpenForm "frm_GSG_Access_Rights", acFormDS, , When I enter something in the where...
1
by: silen | last post by:
i am using Access2000. Currently i had a main form call "frmDownload" and sub form "fsubAdmmission". Under the fsubAdmmission, i do have another sub form "fsubHospital". Once i link my application to...
5
by: Lebbsy | last post by:
After displaying search results, I want to be able to double click the identity number field and then the input form SubmissionDetails becomes the display form for the results of the data matching...
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: 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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
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,...
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
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...

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.