R
red_ned
I have a combo box which takes its data from a query of a table to
distinguish valid from invalid options.
Once you drop down the choices you select from the remaining legitimate,
chosing this option then drops info from the table into other places on the
form.
To give you an idea this is a car permit database, so once you select say
Annual renewal it should
1) add the amount of time in months to the start date (which defaults to
today) and puts result into an expirey date box.
2) drop the cost of this permit into the cost box.
3) drop a small code into the permit number which prefixes a 6 digit number
that is to be typed in.
All this data is held inside the "Carpark Permit Types" table.
I got the cost to drop into the box but the expirey date adds 300 and ends
up saying xx month 1900, worse still the permit type choice vanishes so you
cant see it. I am a novice at this and have had this thrown into my lap, all
help is greatly appreciated.
What i need is the convention to add a time (in months) to a date, and a
quick guide to what im doing wrong with the coding for the dropdown box.
CODE...
Private Sub CP_Permit_Type_Change()
Dim permittype As String
Dim chargeamt As Currency
Dim dbs As Database
Dim rst As DAO.Recordset
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("Carpark Permit Types")
permittype = Forms![Travel Permits]![CP Permit Type].Value
'If Forms![Travel Permits]![CP Fee Due].Value <> "" Then Exit Sub
With rst
.Index = "PrimaryKey"
.Seek "=", Forms![Travel Permits]![CP Permit Type].Value
If Not .NoMatch Then
chargeamt = ![Charge]
End If
End With
Forms![Travel Permits]![CP Permit Type].Value = permittype
Forms![Travel Permits]![CP Fee Due].Value = chargeamt
End Sub
A great big THANKS IN ADVANCE! to all.
ned
distinguish valid from invalid options.
Once you drop down the choices you select from the remaining legitimate,
chosing this option then drops info from the table into other places on the
form.
To give you an idea this is a car permit database, so once you select say
Annual renewal it should
1) add the amount of time in months to the start date (which defaults to
today) and puts result into an expirey date box.
2) drop the cost of this permit into the cost box.
3) drop a small code into the permit number which prefixes a 6 digit number
that is to be typed in.
All this data is held inside the "Carpark Permit Types" table.
I got the cost to drop into the box but the expirey date adds 300 and ends
up saying xx month 1900, worse still the permit type choice vanishes so you
cant see it. I am a novice at this and have had this thrown into my lap, all
help is greatly appreciated.
What i need is the convention to add a time (in months) to a date, and a
quick guide to what im doing wrong with the coding for the dropdown box.
CODE...
Private Sub CP_Permit_Type_Change()
Dim permittype As String
Dim chargeamt As Currency
Dim dbs As Database
Dim rst As DAO.Recordset
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("Carpark Permit Types")
permittype = Forms![Travel Permits]![CP Permit Type].Value
'If Forms![Travel Permits]![CP Fee Due].Value <> "" Then Exit Sub
With rst
.Index = "PrimaryKey"
.Seek "=", Forms![Travel Permits]![CP Permit Type].Value
If Not .NoMatch Then
chargeamt = ![Charge]
End If
End With
Forms![Travel Permits]![CP Permit Type].Value = permittype
Forms![Travel Permits]![CP Fee Due].Value = chargeamt
End Sub
A great big THANKS IN ADVANCE! to all.
ned