Funny Split Form Bug?

K

Kaoli

Hi all, I just found a funny thing in Ms Access 2007

I have a splitform, in the form Header I have a combobox to call a rowsource
from a table(period),which have Period,Start date, End Date

when I update/add the record at the form is OK! but when I update/add the
record in datasheet problem will occurs for 2nd column and 3rd column,
cboperiod.column(1)&(2)=null why ?

is it a bug? or my code got problem?
I tried this about few weeks only found different between form and datasheet
key in.

my code as per below;

Private Sub Form_BeforeUpdate(Cancel As Integer)
If IsNull(Me.YearMonth) Then
Me.YearMonth = Me.CboPeriod
Else
End If

Dim dCurrentDate As Date, dStart As Date, dEnd As Date, dtest As Date

'Set date as region date format or not ms access will treat as mm/dd/yyy
dCurrentDate = Format(Me.TranDate, "dd/mm/yyyy")
dStart = Format(Me.CboPeriod.Column(1), "dd/mm/yyyy")
dEnd = Format(Me.CboPeriod.Column(2), "dd/mm/yyyy")

If dCurrentDate < dStart Or dCurrentDate > dEnd Then
MsgBox "Invalid Date, Date must within selected period"
Cancel = True
End If
End Sub

Private Sub cboPeriod_AfterUpdate()
Dim dStart As Date, dEnd As Date, dtest As Date
Me.Requery
Me.Refresh
Me.CboPeriod.DefaultValue = Me.CboPeriod
End Sub

Private Sub Form_Load()
Me.Requery
Me.Refresh
End Sub
 

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