Import to Access errors out

B

bear

Hello Sue,

After all it was Access database field type issue.
Thanks for your help


suemvp wrote on Thu, 07 January 2010 18:3
I disagree. If you set a database field to a certain value, but read out a
different value from the same field, then the cause would seem to lie in the
database. Nothing else has touched the data. It's certainly not an Outlook
issue. I have no idea what in Access could cause this other than having the
wrong data type for the field. If you pursuse this on an Access forum, which
I would recommend, be sure to reduce the code you share down to a specific
snippet that deals just with the raw vaues, not with Outlook properties.
Mentioning Outlook will only distract the Access experts from your real
issue.

Also, there is no need to use both CSng() and CDbl() on the value that
DateDiff returns. Use whichever is more appropriate to your expected data.
--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


bear said:
Hello Sue,

I was trying to get certain format, but you right, I do not need it:


Set rst = dbs.OpenRecordset("Form")
rst.AddNew
Set ups = con.UserProperties
TotalM = DateDiff("n", ups.Find("Start1"), ups.Find("End2"))
TotalH = CSng(TotalM / 60)
rst!LengthofAppt = CDbl(TotalH)

If CDbl(TotalH) is 4.683333, rst!LengthofAppt is rounded up to 5.
Anywhere else in the code rst! value can be anything such 0.003 or
111#$23. I do not think it has to do with Access as fields in the table
are all the same.

suemvp wrote on Mon, 04 January 2010 21:09
I don't understand why you're using Format() at all in this scenario. If
you want to round the hour value to two decimal points, just use Round().

In any case, if the database isn't accepting or reporting the correct
value, that sounds like an Access issue, not an Outlook issue. I can't
help you with that.

"bear" <swin_1234[at]yahoo[dot]com> wrote in message
Hello Sue,

My Access table takes in Numeric value in a fixed format 0.000.
I tied both methods, or combination of, you suggested, still no luck.
For rst!LengthofAppt = CDbl(TotalH), even if CDbl(TotalH) 5.01,
rst!LengthofAppt is 5.
A

Set ups = con.UserProperties
TotalM = DateDiff("n", ups.Find("Start1"),
ups.Find("End2"))
TotalH = CSng(Format((TotalM / 60), "#,##0.00"))
rst!LengthofAppt = CDbl(TotalH)

B

Set ups = con.UserProperties
TotalM = DateDiff("n", ups.Find("Start1"),
ups.Find("End2"))
TotalH = CSng(Format((TotalM / 60), "#,##0.00"))
rst!LengthofAppt = CSng(TotalH)


suemvp wrote on Fri, 01 January 2010 13:16
Maybe because LengthofAppt is set up in the database as an Integer
field? In any case, Format() returns a string, so if LengthofAppt is a
numeric field of any kind, you should use a converter method like
CDbl() or CSng() to convert that string into a numeric value.

"bear" <swin_1234[at]yahoo[dot]com> wrote in message
In this example:
Set rst = dbs.OpenRecordset("Form")
rst.AddNew
Set ups = con.UserProperties
TotalM = DateDiff("n", ups.Find("Start1"),
ups.Find("End2"))
TotalH = Format((TotalM / 60), "#,##0.00")
rst!LengthofAppt = TotalH


If TotalH is 1.02, why does rst!LengthofAppt becomes 1, instead of
1.02?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top