N
niuginikiwi
Hi,
I have a command button that inserts my selections on values in txt fields,
combo boxes and list boxes into different tables...
What I would like to do is before inserts a done, I would like a customised
warning saying that you are trying to insert the selected values into the
database and should give me an option of saying YES or NO. If yes is clicked,
it should insert, if No is clicked, nothing happens.
Im pretty sure its simple but I can't figure it out myself.
Below is the code on the command button.
Private Sub btnAppend_Click()
Dim DB As DAO.Database
Dim rsApplication As DAO.Recordset
Dim rsApplicationDetails As DAO.Recordset
Dim vPlanting As Variant, i As Integer
Dim vProduct As Variant
Dim lApplicationID As Long
Set DB = CurrentDb
Set rsApplication = DB.OpenRecordset("tblApplications")
Set rsApplicationDetails = DB.OpenRecordset("tblApplicationDetails")
For Each vPlanting In lstPlantings.ItemsSelected
With rsApplication
.AddNew
!ApplicationDate = txtApplicationDate
!OperationID = cboOperation
!EmployeeID = cboEmployee
!PlantingDetailsID = lstPlantings.ItemData(vPlanting)
!WaterRate = txtWaterRate
!TankSize = txtTankSize
lApplicationID = !ApplicationID
.Update
End With
For Each vProduct In lstRates.ItemsSelected
With rsApplicationDetails
.AddNew
!ApplicationID = lApplicationID
!ProductDetailsID = lstRates.ItemData(vProduct)
.Update
End With
Next vProduct
Next vPlanting
rsApplication.Close
rsApplicationDetails.Close
End Sub
I have a command button that inserts my selections on values in txt fields,
combo boxes and list boxes into different tables...
What I would like to do is before inserts a done, I would like a customised
warning saying that you are trying to insert the selected values into the
database and should give me an option of saying YES or NO. If yes is clicked,
it should insert, if No is clicked, nothing happens.
Im pretty sure its simple but I can't figure it out myself.
Below is the code on the command button.
Private Sub btnAppend_Click()
Dim DB As DAO.Database
Dim rsApplication As DAO.Recordset
Dim rsApplicationDetails As DAO.Recordset
Dim vPlanting As Variant, i As Integer
Dim vProduct As Variant
Dim lApplicationID As Long
Set DB = CurrentDb
Set rsApplication = DB.OpenRecordset("tblApplications")
Set rsApplicationDetails = DB.OpenRecordset("tblApplicationDetails")
For Each vPlanting In lstPlantings.ItemsSelected
With rsApplication
.AddNew
!ApplicationDate = txtApplicationDate
!OperationID = cboOperation
!EmployeeID = cboEmployee
!PlantingDetailsID = lstPlantings.ItemData(vPlanting)
!WaterRate = txtWaterRate
!TankSize = txtTankSize
lApplicationID = !ApplicationID
.Update
End With
For Each vProduct In lstRates.ItemsSelected
With rsApplicationDetails
.AddNew
!ApplicationID = lApplicationID
!ProductDetailsID = lstRates.ItemData(vProduct)
.Update
End With
Next vProduct
Next vPlanting
rsApplication.Close
rsApplicationDetails.Close
End Sub