Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

DATE problem

hi experts

what i want

i have one date filed in form . first time i insert date 12/03/08 . when second time this (12/03/08) date insert date some message will show

i want to show mesage SBO_Application.MessageBox("20")

if it is True

but i got

SBO_Application.MessageBox("21")

plz help me ....

my code

Private Function test_con(ByVal tdt1 As String) As Boolean

Dim RS As SAPbobsCOM.Recordset

Dim Bob As SAPbobsCOM.SBObob

' Dim z As String

Try

Bob = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoBridge)

RS = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)

RS.DoQuery("SELECT convert(varchar(12),U_todt,103) FROM [@suvr] WHERE U_todt ='" & tdt1 & "' ")

RS.MoveFirst()

Do While Not RS.EoF

tdt = RS.Fields.Item("U_todt").Value

Return True

Loop

Catch ex As Exception

MessageBox.Show(ex.Message)

Return False

End Try

End Function

If (pVal.ItemUID = "todt") And (pVal.EventType = SAPbouiCOM.BoEventTypes.et_LOST_FOCUS) And pVal.BeforeAction = False Then

Dim todt1 As String

todt1 = oForm.Items.Item("todt").Specific.value

Dim test As String

test = test_con(todt1)

If test = True Then

SBO_Application.MessageBox("20")

Else

SBO_Application.MessageBox("21")

End If

end if

Former Member
Former Member replied

Im not usre if I understand it correctly. Try to change it as

Private Function test_con(ByVal tdt1 As String) As Boolean

Dim RS As SAPbobsCOM.Recordset

Dim Bob As SAPbobsCOM.SBObob

' Dim z As String

Try

Bob = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoBridge)

RS = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)

RS.DoQuery("SELECT convert(varchar(12),U_todt,103) FROM @suvr WHERE U_todt ='" & tdt1 & "' ")

RS.MoveFirst()

dim x as integer

x = 0

Do While Not RS.EoF

'tdt = RS.Fields.Item("U_todt").Value

x = x + 1

'Return True

Loop

if x > 1 then return True

Catch ex As Exception

MessageBox.Show(ex.Message)

Return False

End Try

End Function

or the problem is in line

tdt = RS.Fields.Item("U_todt").Value

you are accesing field todt, but this field isnt in recordset, you must change result with AS

RS.DoQuery("SELECT convert(varchar(12),U_todt,103) as X FROM @suvr WHERE U_todt ='" & tdt1 & "' ")

and

tdt = RS.Fields.Item("X").Value

Edited by: Petr Verner on Sep 5, 2008 8:24 AM

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question