R
red_ned
I got roped into updating a database for work. I made pretty much all the
changes fine, then my knowledge dried up.
I have a combo box that selects a permit type, once selected that permit
type drops the correct price into the "cost" at the bottom of the page, and
then adds the correct amount of months to the current date and drops result
in an "expires" field, then it adds a specific prefix to the permit number
before it can be printed.
The table that contains the permit types has all the information that this
box should need, due to people being able to update this info there is a sub
menu including the valid key as to if this permit still exists. The dropdown
box then only shows the valid types.
This should have been relatively easy, however, i started doing the code for
the first 2 portions and when you select the dropdown permit it does drop the
cost down but then it adds the ID column to the date (so reading 4th Jan 1900
etc) and then the name disapears from the combo box so not showing what has
been selected.
After a whole day of pulling out my hair im asking for help.
Here is what i believe to be the relevant section of code.. Thanks to anyone
who can help this sad rapidly greying man.
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
changes fine, then my knowledge dried up.
I have a combo box that selects a permit type, once selected that permit
type drops the correct price into the "cost" at the bottom of the page, and
then adds the correct amount of months to the current date and drops result
in an "expires" field, then it adds a specific prefix to the permit number
before it can be printed.
The table that contains the permit types has all the information that this
box should need, due to people being able to update this info there is a sub
menu including the valid key as to if this permit still exists. The dropdown
box then only shows the valid types.
This should have been relatively easy, however, i started doing the code for
the first 2 portions and when you select the dropdown permit it does drop the
cost down but then it adds the ID column to the date (so reading 4th Jan 1900
etc) and then the name disapears from the combo box so not showing what has
been selected.
After a whole day of pulling out my hair im asking for help.
Here is what i believe to be the relevant section of code.. Thanks to anyone
who can help this sad rapidly greying man.
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