UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Invalid Data Type Passing Through Parameter, Access 2010 Web    
 
   
Metron4
post May 14 2012, 06:29 PM
Post #1

UtterAccess Addict
Posts: 114



Hello,

I am receiving an invalid data type error when passing a value from a form control (text box) to a named data macro parameter in my table. The form control value is getting its value through a TempVar. I have almost this exact same setup working elsewhere in my database. The only difference is that in the working version, the form control is using a control source directly tied to a field, whereas in this version the control source is using the TempVars collection to display the temporary variable (Control Source = [TempVars]![MyVariable]). Please see attached image.

The source of the TempVar is the same data type as the table field. So why the error?
Attached File(s)
Attached File  TempVar.jpg ( 29.29K ) Number of downloads: 22
 
Go to the top of the page
 
+
RCJT
post May 18 2012, 05:47 PM
Post #2

UtterAccess Addict
Posts: 171
From: Southern CA



Have you run it through the debug process to ensure the varialbes are what you expect in terms of value and data type?
Go to the top of the page
 
+
Metron4
post May 21 2012, 06:25 PM
Post #3

UtterAccess Addict
Posts: 114



Yes, I have. I think the problem stems from the fact that the Control Source value in the form ([TempVars]![CurrentProjectID]) has NO data type, and therefore can't be matched by the lookup field in my table that contains the matching item. Thus, the error message "The field 'ProjectID' cannot accept the data type supplied by Setfield".

I have tried adding the original table that contains the lookup field and doing some fancy-schmancy cross-referencing, but to no avail. Because this is a New record, I can't get the matching item to even show up, let alone reference it.

How do you pass a value through a form, through a data macro and into a table when both start and end values come from the same table?
Go to the top of the page
 
+
RCJT
post May 21 2012, 06:42 PM
Post #4

UtterAccess Addict
Posts: 171
From: Southern CA



I haven't worked a ton with the macros. I generally use VBA. When doing your comparison, you should be able to change the datatype. From the Visual Basic for Applications Window hit help, then search on Type Conversion Functions to find different functions for converting data types.


CODE
'Just a code snippit, won't work as written

Dim lngCurrProject as Long
Dim strCurrProject as String

If (lngCurrentProject = strCurrProject) then... would fail

If(lngCurrentProject = cString(strCurrProject Then...would work.


Not sure if that helps or not (IMG:style_emoticons/default/smile.gif)

JT



Go to the top of the page
 
+
Metron4
post May 22 2012, 04:22 PM
Post #5

UtterAccess Addict
Posts: 114



Sorry, this is a web database, and VBA is not allowed.

Let me try this in a more visual way. I prepared a graphic to explain what it is I am trying to do. Basically, the powers that be wish to track project status so that reports can be generated to determine how long a project was in a given status. Please see the attached image.

Please feel free to tell me I am doing it all wrong. (IMG:style_emoticons/default/smile.gif)
Attached File(s)
Attached File  PassValue.jpg ( 261.37K ) Number of downloads: 9
 
Go to the top of the page
 
+
Metron4
post May 24 2012, 08:09 PM
Post #6

UtterAccess Addict
Posts: 114



OK, I solved my problem. I had been avoiding using the ProjectID field as a control source for my Status Change form because the form was designed to open to a new record, and that field would have shown as blank. I realized I could set a macro for the OnLoad event that used my TempVar to pull the matching ProjectID into the control. Basically I used LookupRecord, WHERE [Projects].[ProjectID] = [TempVars]![CurrentProjectID], then SetProperty Value = [TempVars]![[CurrentProjectID]. I also did not realize I could put a value other than zero or one in the value for SetProperty. You just have to prefix it with the equal sign.

Geez, this stuff is HARD.
Go to the top of the page
 
+

Thank you for your support! Reply to this topicStart new topic

Jump To Forum:
 



RSS Go to Top  ·  Lo-Fi Version Time is now: 20th June 2013 - 12:32 AM

Tag cloud: