473,387 Members | 3,801 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,387 software developers and data experts.

Access 97 to 2010 conversion problem

I have recently converted a database built in Access 97 to Access 2010. In 2010 I am now having a problem with an control on the form. The control now states #Name? as the shown value. I have the text box Control source set as:

Expand|Select|Wrap|Line Numbers
  1. = DCount("[RN]","tbl_DIC","[Location] = '" & [myShop] & "'  AND [Removed_Date] > #" & DateAdd("h",-24,[myDate]) & "# and  [Removed_Date] <= #" & [myDate] & "# and [Executed] ")
myShop = Variable from vb
myDate = Variable from vb
RN = Table value
Removed_Date = Table value
Executed = Table value

Can anyone tell me why this is not working. I have been back and forth and can not find a problem with the dcount function. This method works just fine in 97.

Thank you in advance for the help.
Feb 6 '13 #1

✓ answered by TheSmileyCoder

Now I have never used Ac97 myself, but if memory serves I recall someone else asking something similar, in which it was determined that you can't access form variables like that(like in the Dlookup) anymore, in the more recent versions of access.

The simplest workaround is to use 2 hidden and unbound textboxes, assign values to them in the forms load event, and use their reference in your dlookup syntax.

14 2766
Rabbit
12,516 Expert Mod 8TB
The most likely cause is a variable name, field name, or table name that got changed in the conversion. I would check all those references.
Feb 6 '13 #2
TheSmileyCoder
2,322 Expert Mod 2GB
I believe it is related to trying to use a VB variable directly in the control source. Can you say a bit more about myShop and myDate? How are they declared within the vb environment, and how and when are they set?
Feb 6 '13 #3
The variables are

Public myDate As Date
Public myShop As String

They are set on load of the form through open args, I have a parse function that allows me to send multiple variables.
Feb 6 '13 #4
TheSmileyCoder
2,322 Expert Mod 2GB
Now I have never used Ac97 myself, but if memory serves I recall someone else asking something similar, in which it was determined that you can't access form variables like that(like in the Dlookup) anymore, in the more recent versions of access.

The simplest workaround is to use 2 hidden and unbound textboxes, assign values to them in the forms load event, and use their reference in your dlookup syntax.
Feb 6 '13 #5
NeoPa
32,556 Expert Mod 16PB
Spot on Smiley. I would add though, that 2010 has session variables available that would probably be a more appropriate substitute.
Feb 7 '13 #6
TheSmileyCoder
2,322 Expert Mod 2GB
I would say that its certainly possible to use the session variables (Tempvars), however I see no reason for those variables to become global (at least from what has been described), and would at least personally prefer the hidden control approach.
Feb 7 '13 #7
NeoPa
32,556 Expert Mod 16PB
Yes. It was TempVars I meant ;-)

I still use the control approach myself sometimes, but I'm still using 2003 mainly of course. If that makes better sense to you then it sounds fine to me :-)
Feb 7 '13 #8
Thank you all for you quick response on this. Setting hidden controls worked perfectly. I will do some research into the TempVars as I am not familiar with that.
Feb 7 '13 #9
TheSmileyCoder
2,322 Expert Mod 2GB
Your welcome. Neopa, Rabbit and me are pleased to help.
Feb 7 '13 #10
zmbd
5,501 Expert Mod 4TB
@2.W.M.C.:
I've no problem with using the public variables in the declaration section of my forms within dlookup.
In fact, I have one form where I store an SQL that is built based on user choices from an opening form... passing the values as openarg. This is a database that was in v2003 and now in v2010 (finally just bit the bullet and saved it as ACCDB as I wanted to remake the switchboard using the new navigation control).
I'd be willing to post an example DB with a very simple form that shows this to work.


@Soulspike:
I'm glad you have a solution; however, the way you built the criteria for the dlookup function is a pet-peeve of mine. I don't blame you, I blame MS and every textbook author out there that shows programmers to build the string within the criteria parameter of the dlookup function, or within any function for that matter.

You have this huge string being built within the dlookup function... and I'll tell you now, the more complex the string - more likely it's going to choke on you when this function resolves - I found this out the hard way!

First pull that thing out of the function and assign it to a "strVAR" so that you can see the string. You use that strVAR instead within the function.

So you'll have something like:
Expand|Select|Wrap|Line Numbers
  1. 'lead-in code omitted
  2. strVAR= "[Location] = '" & [myShop] & _
  3.     "'  AND [Removed_Date] > #" & _
  4.     DateAdd("h",-24,[myDate]) & _
  5.     "# and  [Removed_Date] <= #" & _
  6.     [myDate] & "# AND [Executed]"
  7. '
  8. 'place your stop or debug.print strVAR here.
  9. '
  10. strSOMETHING= DCount("[RN]","tbl_DIC", strVAR) 
  11.  
Now you can either debug print or place a stop command in the code to take a look at what you are actually getting back

I find that line 6 above to be interesting:
"# AND [Executed]"
That is not going to return the value from the control or record field [Executed], so your are getting that exact string appended after your date; thus you might have something like this for the resolved string:

"[Location] = 'exampleName' AND [Removed_Date] >#02/07/2013# AND [Removed_Date] <= #02/08/2013# AND [Executed]"

Is that what you wanted? I suspect that is where your #Name error is comming from.
Feb 8 '13 #11
I will try out using the strVar method you are showing above, it does sound cleaner. This forum is a great place for me to learn better ways to do it. My biggest problem being self taught is keeping things clean and organized in my code. So I appreciate the ideas to help me improve that.

As far as the string
Expand|Select|Wrap|Line Numbers
  1. "[Location] = 'exampleName' AND [Removed_Date] >#02/07/2013# AND [Removed_Date] <= #02/08/2013# AND [Executed]"
That looks right to me as [Executed] is a True/False value and I only want the trues so access is only counting those as a part of that function.
Feb 8 '13 #12
zmbd
5,501 Expert Mod 4TB
AND [Executed]
I was wondering if that was a Boolean datatype. Personally, I would have been explicit with the data check: AND [Executed]= True; however, I come from the old school where a lot things had to be explicitly defined and I'm always suspect that the engine wont look at things correctly.
Feb 8 '13 #13
NeoPa
32,556 Expert Mod 16PB
Z:
I would have been explicit with the data check: AND [Executed]= True
I'm afraid that would not be recommended Z.

Apart from being technically incorrect ((BooleanVar = True) =/=> (BooleanVar)) it also indicates a lack of the appreciation that the result required is exactly what a Boolean value is.

Technically, any Boolean result is treated as being on the True path as long as it is not zero. Thus, an arithmetic equivalence can only be deemed correct if it is in the form (BooleanVar <> False). That said, my bigger gripe with that approach is that it indicates a lack of understanding of what Booleans are. It really makes no sense to convert a Boolean value into Boolean by comparing it with another Boolean. Very similar to using tautology in the language.
Feb 9 '13 #14
zmbd
5,501 Expert Mod 4TB
Simply forgot that the [Executed] was actually returning the value from the table and not refering just to the field name. I've been up since 05h00 Thursday... perhaps a nap is in order.
Feb 9 '13 #15

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

Similar topics

3
by: prakashwadhwani | last post by:
I have just been asked to port an Access 97 app from an old Pentium 3 to a new Pentium Core-2-Duo PC. On the new PC, Office 2003 is installed. On opening the database, Access provided me with an...
1
by: phill86 | last post by:
Hi, I have an access 2010 database that I want to convert to an SQL Server database and I need to know if the data macros in access will still work in the SQL database or will i have to create...
5
by: jaad | last post by:
Hello, I have a database that was written in access 2007 on my pc. I wanted to work off site with the database so I uploaded it onto my laptop which is loaded with access 2010 beta. When I...
2
by: sierra7 | last post by:
It seems Access 2010 is associating an 'input mask' or field type with a combo box when a form is opened, even though there is no Format setting on the control. I have a form which has been...
2
by: dougancil | last post by:
I have a user who had deleted some records from a database today using Access 2010. They have an ID field that's autonumbered. They have No Duplicates allowed. When they created a new record today,...
0
by: Andolino | last post by:
In Access 2010 I get a Write Conflict error - "This record has been changed by another user..." In Access 2007 this Code is working - why? Private Sub Form_BeforeUpdate(Cancel As Integer) Dim...
1
by: Alan Yim | last post by:
Hi folks, My company recently upgraded our Office suite from 2003 to 2010. The problem in particular is with an Access database that was originally designed in Access 2003. The code in question...
2
by: Bill Boord | last post by:
I need to be able to shut off the AutoCorrect "feature" within Access 2010 code. I have utilized Application.SetOption with method strings for other startup requirements, but I cannot seem to find a...
1
dsatino
by: dsatino | last post by:
I have numerous applications built in Access 2000/2003 that all use ODBCdirect workspaces to access various non-Access databases. Unfortunately, ODBCdirect is 'no longer supported'in Access 2010 and...
1
by: Music Man | last post by:
Greetings All: I built a database in Microsoft SQL Server 2000 and used Microsoft Access 2010 as the front end. The database is used to keep track of "issues" that rise out of my employment. ...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...

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.