Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / General MS InfoPath Questions / February 2006

Tip: Looking for answers? Try searching our database.

Type mismatch Problem

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
rg66 - 13 Feb 2006 09:13 GMT
Hello

hope some one canhelp me out

I have a script which is run un VBScript

I have two fields

1. Date From  and Date To
2. The  Format is Date and Time YY.MM.DD HH:MM

Sandeep has helped me so I used this script in the OnAfterChange of
Field Date To

Sub msoxd_my_datum_bis_OnAfterChange(eventObj)
Dim nodeDate1
Dim nodeDate2
Dim dtVal_Von
Dim dtVal_Bis
Dim faktorwert

Set nodeDate1 =
XDocument.DOM.selectSingleNode("/my:meineFelder/my:reisediäten/my:exp_land/my:datum_von")
Set nodeDate2 =
XDocument.DOM.selectSingleNode("/my:meineFelder/my:reisediäten/my:exp_land/my:datum_bis")
Set nodeFaktor =
XDocument.DOM.selectSingleNode("/my:meineFelder/my:reisediäten/my:exp_land/my:dsatz_faktor")

if nodeFaktor.getAttribute("xsi:nil") then
    nodeFaktor.removeAttribute("xsi:nil")
End if

dtVal_Von = nodeDate1.Text
dtVal_Bis = nodeDate2.Text

' Fügen Sie hier den Code zum Wiederherstellen des globalen Zustandes
ein.

If eventObj.IsUndoRedo Then
    ' Ein Rückgängig- oder Wiederholen-Vorgang wurde durchgeführt und
das DOM ist schreibgeschützt.
    Exit Sub
End If

' Eine Änderung am Feld wurde vorgenommen und das DOM ist
beschreibbar. Fügen Sie hier den Code für die Reaktion auf die
Änderung ein.
faktorwert = Faktor(dtVal_Von, dtVal_Bis)
nodeFaktor.text = faktorwert

End Sub

The Function Faktor(dtVal_Von, dtVal_Bis) looks like this

Function Faktor(Datum_Start, Datum_Ende)
Dim Minuten
Dim A
Dim Bruchteil
Dim Zeilen

Minuten = DateDiff("n", Datum_Start, Datum_Ende)

'Berechnung des Faktors
Faktor = 0
Zaehler = 0
A = 0
Bruchteil = 0.333333333333
Zeilen = 1

While Zaehler <= Minuten
   Zaehler = Zaehler + 1
   A = A + 1

   If A = 5 * 60 + 1 Then
           Faktor = Faktor + Bruchteil
   ElseIf A = 8 * 60 + 1 Then
           Faktor = Faktor + Bruchteil
   ElseIf A = 12 * 60 + 1 Then
           Faktor = Faktor + Bruchteil
           Zaehler = Zaehler + 12 * 60
           A = 0
   End If
Wend

Faktor = cdbl(Faktor)

End Function

When I go to the view form and I select the days I get a type mismatch
in this line from the function faktor:

Minuten = DateDiff("n", Datum_Start, Datum_Ende)

And it states that Datum_Ende is the problem.  Strangley Datum_Start
works.

Any idea what is wrong?

Thanks for any help!!

Robert
rg66 - 13 Feb 2006 10:42 GMT
WHat I figured out right now is the following:

If the field date 1 and date 2 have the format text then the script
works.

If I choose the format date and time then it does not work.  Any idea
way not.

I need to figure out how many minutes have passed between date 1 and
date 2 that's why I need the format date and time.

Robert
S.Y.M. Wong-A-Ton - 14 Feb 2006 11:52 GMT
If you use data type "Date and Time (dateTime)", you will find InfoPath using
dates with the following format in the background: YYYY-MM-DDTHH:MM:SS. So
you may have to parse your dates to get them in the correct format before you
use them.
---
S.Y.M. Wong-A-Ton

> WHat I figured out right now is the following:
>
[quoted text clipped - 8 lines]
>
> Robert
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.