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

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
2 Pages V  1 2 >  (Go to first unread post)
   Reply to this topicStart new topic
> Data Type Mismatch, Any Version    
 
   
startingover0001
post Jan 21 2020, 06:43 PM
Post#1



Posts: 256
Joined: 13-November 10
From: 37745


Maybe somebody can point out my blind spot here.

How can you get a datatype mismatch just from binding a form to a table?

I have a form with 4 UNBOUND fields on it. A button runs a convert function and places the results of the first 3 textboxes into the 4th.

As long as the form is not bound to a table, it works perfectly. But as soon as you bind it to a table, you get the error #13. No table fields have been added. Still all unbound.

it should be noted that I was borrowing some code I'd found just to play around with it and test it. When I first added it to my bound form, it worked fine. I tried converting the number portion to a string because ultimately, the result would be a combination of numbers and symbols such as the # symbol. I duplicated the table from scratch just in case the original table had gotten corrupted but it made no difference. A variant field would prevent type mismatches but you can't set a table field as a variant, not to mention the overhead they have.



any suggestions?
This post has been edited by startingover0001: Jan 21 2020, 06:44 PM
Go to the top of the page
 
theDBguy
post Jan 21 2020, 06:45 PM
Post#2


UA Moderator
Posts: 77,506
Joined: 19-June 07
From: SunnySandyEggo


Hi. Can you post a copy of the form, so we can take a look?

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Access Website | Access Blog | Email
Go to the top of the page
 
startingover0001
post Jan 21 2020, 07:06 PM
Post#3



Posts: 256
Joined: 13-November 10
From: 37745


Open the form...enter 3 numbers in the first 3 boxes. Hit the button.

do this both unbound and bound to the table.
Go to the top of the page
 
startingover0001
post Jan 21 2020, 07:08 PM
Post#4



Posts: 256
Joined: 13-November 10
From: 37745


I keep trying to upload a zip file and it keeps telling me no file chosen.
Go to the top of the page
 
startingover0001
post Jan 21 2020, 07:19 PM
Post#5



Posts: 256
Joined: 13-November 10
From: 37745


Does this forum not accept 7zip files?
Go to the top of the page
 
cheekybuddha
post Jan 21 2020, 08:32 PM
Post#6


UtterAccess Moderator
Posts: 12,291
Joined: 6-December 03
From: Telegraph Hill


>> Does this forum not accept 7zip files? <<
Unfortunately not. frown.gif

Perhaps that will change in the near future.

In the meanwhile, you can use 7zip to create a .zip file.

thumbup.gif

d

--------------------


Regards,

David Marten
Go to the top of the page
 
startingover0001
post Jan 21 2020, 08:41 PM
Post#7



Posts: 256
Joined: 13-November 10
From: 37745


That's what I meant. I zipped the file with 7zip. I didn't mean I had 7 files to zip lol.
Go to the top of the page
 
cheekybuddha
post Jan 21 2020, 08:42 PM
Post#8


UtterAccess Moderator
Posts: 12,291
Joined: 6-December 03
From: Telegraph Hill


7zip creates .7z files by default, but you can choose to create .zip files instead.

--------------------


Regards,

David Marten
Go to the top of the page
 
startingover0001
post Jan 21 2020, 08:46 PM
Post#9



Posts: 256
Joined: 13-November 10
From: 37745


Yep! That's how it was zipped. frown.gif

For what it's worth, there's only 1 table and one form in it. You can duplicate it easily.

create a table with 4 fields...R,G,B and Hex

create a form with 4 fields...unbound and a button. Call them what you want. Add this code:

Option Compare Database
Option Explicit

Function RGBtoHEX(r As Byte, g As Byte, b As Byte) As Variant
On Error GoTo RGBtoHEX_Error

Dim HEX1 As Variant, Hex2 As Variant, HEX3 As Variant

If r < 16 Then
HEX1 = 0 & Hex®
Else
HEX1 = Hex®
End If

If g < 16 Then
Hex2 = 0 & Hex(g)
Else
Hex2 = Hex(g)
End If

If b < 16 Then
HEX3 = 0 & Hex(b)
Else
HEX3 = Hex(b)
End If

RGBtoHEX = HEX1 & Hex2 & HEX3

ExitFunction:
Exit Function

RGBtoHEX_Error:

MsgBox "MS Access has generated the following error" & vbCrLf & vbCrLf & "Error Number: " & _
err.Number & vbCrLf & _
"Error Description: " & err.Description, vbCritical, "An Error has Occured!"
GoTo ExitFunction

End Function

Private Sub Command3_Click()
Me.tlong.Value = "#" & RGBtoHEX(Me.r.Value, Me.g.Value, Me.b.Value)
End Sub

Private Sub Form_Load()
DoCmd.GoToRecord , , acNewRec
End Sub

That's it. Bind and unbind the form to the table and see if you get the error msg and if so, why?
This post has been edited by startingover0001: Jan 21 2020, 08:53 PM
Go to the top of the page
 
cheekybuddha
post Jan 21 2020, 08:52 PM
Post#10


UtterAccess Moderator
Posts: 12,291
Joined: 6-December 03
From: Telegraph Hill


Did you compact and repair your db first. There is a 2MB size limit after zipping.

--------------------


Regards,

David Marten
Go to the top of the page
 
startingover0001
post Jan 21 2020, 08:54 PM
Post#11



Posts: 256
Joined: 13-November 10
From: 37745


Did better than that...created an entirely new db just for the test to send. 1 table, no data, and 1 form.
Go to the top of the page
 
cheekybuddha
post Jan 21 2020, 09:05 PM
Post#12


UtterAccess Moderator
Posts: 12,291
Joined: 6-December 03
From: Telegraph Hill


You are probably passing Null when you bind the form.

Try:
CODE
Private Sub Command3_Click()
  Me.tlong.Value = "#" & RGBtoHEX(Nz(Me.r.Value, 0), Nz(Me.g.Value, 0), Nz(Me.b.Value, 0))
End Sub


hth,

d

--------------------


Regards,

David Marten
Go to the top of the page
 
startingover0001
post Jan 21 2020, 10:21 PM
Post#13



Posts: 256
Joined: 13-November 10
From: 37745


Unfortunately that did not change the result. Still getting the type mismatch. 'Preciate ya tryin' though!
Go to the top of the page
 
startingover0001
post Jan 22 2020, 08:00 PM
Post#14



Posts: 256
Joined: 13-November 10
From: 37745


Anybody?
Go to the top of the page
 
theDBguy
post Jan 22 2020, 08:25 PM
Post#15


UA Moderator
Posts: 77,506
Joined: 19-June 07
From: SunnySandyEggo


Hi. Did you post a test file?

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Access Website | Access Blog | Email
Go to the top of the page
 
startingover0001
post Jan 23 2020, 02:08 PM
Post#16



Posts: 256
Joined: 13-November 10
From: 37745


Everytime I try to post it, it accepts that I've chosen a file, but upon hitting upload, it says nothing was chosen. That's why since it was so small, I posted the code above.
Go to the top of the page
 
theDBguy
post Jan 23 2020, 02:11 PM
Post#17


UA Moderator
Posts: 77,506
Joined: 19-June 07
From: SunnySandyEggo


Hi. Just a thought... Try using Windows Compressed Folder format to zip your file (instead of using 7Zip).

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Access Website | Access Blog | Email
Go to the top of the page
 
startingover0001
post Jan 23 2020, 06:50 PM
Post#18



Posts: 256
Joined: 13-November 10
From: 37745


I did that the other day as well and it wouldn't take it but it seems to have this time (I think lol)
Attached File(s)
Attached File  test__2_.zip ( 119K )Number of downloads: 1
 
Go to the top of the page
 
startingover0001
post Jan 27 2020, 01:48 PM
Post#19



Posts: 256
Joined: 13-November 10
From: 37745


anybody?
Go to the top of the page
 
cheekybuddha
post Jan 27 2020, 02:37 PM
Post#20


UtterAccess Moderator
Posts: 12,291
Joined: 6-December 03
From: Telegraph Hill


I had a quick look at your db.

It appears to have some corruption as evidenced by the fact that the Hex() function consistently reverts to displaying as lowercase and there is a ghost module which can't open or be removed.

It's as if once created a function or variable called hex() and it conflicted with the built-in function.

You don't by any chance have a table with a field called 'hex' ?

Even a de-compile did not fix it.

I think the answer is to create a brand new db.

Create a new module containing a simple function like:
CODE
Function Test(b As byte) As String

  Test = Hex(b)

End Function


Then import all the other forms and modules into it one by one, compiling after each import. Also check that the function still shows Hex() with the 'H' uppercased after each compile.

If it reverts to lowercase then the last imported object is probably corrupt as well

Once you have imported all the other objects/modules, then recreate the form that was in the db you posted from scratch.

hth,

d

--------------------


Regards,

David Marten
Go to the top of the page
 
2 Pages V  1 2 >


Custom Search


RSSSearch   Top   Lo-Fi    21st February 2020 - 10:59 AM