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

error opening form based on record nr.

64 64KB
Hi,

I had an embedded macro that i converted to VBA code...now, it does not work anymore...

My situation:

I have 2 forms;

- frm_trajecten - list of clients
based on a Query: Q_trajecten which is based on a table tbl_trajecten
- frm_traject_details - details of a client
based on query Q_trajecten_details which is based on table tbl_trajecten

in tbl_trajecten (and both queries i have a field [ID_traject]

On frm_trajecten i have a field [tr_naam_traject] with a hyperlink with the following code;

Expand|Select|Wrap|Line Numbers
  1. Private Sub tr_naam_traject_Click()
  2. On Error GoTo tr_naam_traject_Click_Err
  3.  
  4.         On Error Resume Next
  5.     If (Form.Dirty) Then
  6.         DoCmd.RunCommand acCmdSaveRecord
  7.     End If
  8.     If (MacroError.Number <> 0) Then
  9.         Beep
  10.         MsgBox MacroError.Description, vbOKOnly, ""
  11.         Exit Sub
  12.     End If
  13.     On Error GoTo 0
  14.     DoCmd.OpenForm "frm_traject_details", acNormal, "", "[ID_traject]=" & Nz(ID_traject, 0), , acDialog
  15.     If (Not IsNull(ID_traject)) Then
  16.         TempVars.Add "CurrentID", ID_traject
  17.     End If
  18.     If (IsNull(ID_traject)) Then
  19.         TempVars.Add "CurrentID", Nz(DMax("[ID_traject]", Form.RecordSource), 0)
  20.     End If
  21.     DoCmd.Requery ""
  22.     DoCmd.SearchForRecord , "", acFirst, "[ID_traject]=" & TempVars!CurrentID
  23.     TempVars.Remove "CurrentID"
  24.  
  25.  
  26. tr_naam_traject_Click_Exit:
  27.     Exit Sub
  28.  
  29. tr_naam_traject_Click_Err:
  30.     MsgBox Error$
  31.     Resume tr_naam_traject_Click_Exit
  32.  
  33. End Sub
  34.  
When executing the code i actually opens the form frm_traject_details, which is good.

However, when i try to close the form i get an error message on the line:

Expand|Select|Wrap|Line Numbers
  1. If (Not IsNull(ID_traject)) Then
  2.         TempVars.Add "CurrentID", ID_traject
  3.  
Saying "tempvars can only store data, they cannot store objects"

It stops the code", goes back to the form frm_trajecten after which nothing works anymore (it is stuck)

How can this be corrected ?

Thanks for helping me !
Pierkes
Aug 27 '14 #1

✓ answered by twinnyfo

pierkes,

Try this for your errored line:

Expand|Select|Wrap|Line Numbers
  1. TempVars.Add "CurrentID", ID_traject.Value
I have run across this, too, and it seems TempVars always wants to see the control as the control itself, rather than the value (which is the default in every other location in VBA).

Hope this helps.

3 1152
twinnyfo
3,653 Expert Mod 2GB
pierkes,

Try this for your errored line:

Expand|Select|Wrap|Line Numbers
  1. TempVars.Add "CurrentID", ID_traject.Value
I have run across this, too, and it seems TempVars always wants to see the control as the control itself, rather than the value (which is the default in every other location in VBA).

Hope this helps.
Aug 27 '14 #2
Pierkes
64 64KB
Hi Twinnyfo,

Thank you very much for replying. Tried your suggestion and it now returns from the frm_traject_details to frm_trajecten but the the program does not react to anything anymore.

The only thing i can then do is stop the program and restart it...


Any suggestions on how to proceed?
Aug 27 '14 #3
zmbd
5,501 Expert Mod 4TB
I've split the thread at this point and selected TwinnyFo's answer as best answer to the original question.

The subsequent question/issue that has developed is located at:
http://bytes.com/topic/access/answer...cksup-database
Aug 27 '14 #4

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

Similar topics

1
by: Nagarajan | last post by:
Hello, I am trying to open an application as a VS . NET Project . I get this error every time "Cannot create the offline cache in C:\Documents and Settings\TEMP\My Documents\Visual...
10
by: Norm | last post by:
I must not be understanding something about the use of forms in VB.Net that is different from VB. I have one form running in the background with an icon in the task bar. Right clicking on the icon...
22
by: Br | last post by:
First issue: When using ADPs you no longer have the ability to issue a me.refresh to save the current record on a form (the me.refresh does a requery in an ADP). We usually do this before...
2
by: dbuchanan | last post by:
Hello, I want to open a child form based on the record selected in a dataGridView of the parent form. I want the child form to open with a populated child table based on the selected parent...
4
by: john | last post by:
I created a form via the wizard with 1 main table and 2 one-on-one tables. As i couldn't add a field to the form (a field that I added to the table after creating the form), I googled out that the...
3
by: frenchy | last post by:
I am getting this error in Adobe after struggling with a 'submit' button on an acrobat form that is in production and all the other appdev people in the office are NOT having a problem with. It...
5
by: Usermatre Setepenre | last post by:
Hi, I have a problem whereby I need to delete a record from a form that is based on a Query that has two tables (1 to Many) relationship. I have the following sample of what I have tried:...
5
by: caconklin | last post by:
Access 2003, Windows XP. Currently I am able to open a form - case form - based upon information input by the user in another form - search form. I would like to be able to open the case form...
7
by: chrismaliszewski | last post by:
Hi. I created code which makes dynamically form with bounded controls for all columns. I show it to you below. My problem is, how I have to change this code to create form which record source...
2
by: munkee | last post by:
I use the following code to add the number of records in to my custom navigation within my access database. A simple "Cost x of y" in my sub form that allows me to add costs to a particular activity,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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?
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
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
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...
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,...
0
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...

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.