Combo Box-Text Box

  • Thread starter Thread starter Revned
  • Start date Start date
R

Revned

Hi,

I want that my cmbInstalment will calculate exact date to my txtDueDate
when I choose one of the value from my cmbInstallment

I set the Row Source Type to Value List of my cmbInstallmment

and I have this as my Row Source of my cmbInstallment
"2 Days";"6 Days";"1 Week"

Is it possible?how would I start my code? I am using access 2003

thanks, i appreciate for any help
 
calculate exact date to my txtDueDate? with regards to todays date???

Hopefully I understood your question properly.

Firstly I set your cmb up a little differently by adding a 2nd column. so I
changed the Row Source to:
2;"2 Days";6;"6 Days";7;"1 Week"

where the 1st value = number of days and the 2nd is what you want to appear
to the user. Then on the Format properties tab, I set Column Count = 2 and
the Column Width = 0; 2" (so I hide the first column and display the second
one)

Lastly, I created a afterupdate event on the cmb... to do the automated
calculation of the due date. Below is the code:

Private Sub cmbInstallmment_AfterUpdate()
On Error GoTo Error_Handler
Dim iInstallment As Variant 'number of days

iInstallment = Me.cmbInstallmment
'Only do something if there is a value
If IsNull(dtInstallment) = False Then
Me.txtDueDate = DateAdd("d", iInstallment, Date)
End If

If Err.Number = 0 Then Exit Sub

Error_Handler:
MsgBox "MS Access has generated the following error" & vbCrLf & vbCrLf &
"Error Number: " & _
Err.Number & vbCrLf & "Error Source: cmbInstallmment_AfterUpdate" &
vbCrLf & "Error Description: " & _
Err.Description, vbCritical, "An Error has Occured!"
Exit Sub
End Sub
--
Hope this helps,

Daniel Pineault
http://www.cardaconsultants.com/
For Access Tips and Examples: http://www.devhut.net
Please rate this post using the vote buttons if it was helpful.
 
Back
Top