Hello,
Contrary to common sense, have attached your sample from previous question with a macro to update ‘Shipping Cost’ field.
You have not followed my comment about including ...a great amount of details
as requested in the comments. Here are just a few of the problems as seen:
-
How are amounts determined
-
Where to place the result
-
Is there a base charge
-
Once the record is saved there is no record of what was actually applied
-
Can both single & double box be selected
-
What if an item needs to be applied more than once - labels; 2X bubble wrap; double foam
This is just the surface of potential problems. There was little thought put into posting this question or possibly designing what is really needed to complete the task.
Here is the code used in the Base file:
Option Explicit
Sub CalculateShipping
Dim oForm As Object
Dim oColumns As Object
Dim bBubbleWrap As Boolean
Dim bSingleBox As Boolean
Dim bDoubleBox As Boolean
Dim bFoam As Boolean
Dim bLabels As Boolean
Dim dBaseShipping As Double
Rem Gets Main internal form
oForm = ThisComponent.Drawpage.Forms.getByName("MainForm") 'Get Form
Rem Check if checkboxes selected
bBubbleWrap = oForm.getByName("Bubble Wrap").getCurrentValue()
bSingleBox = oForm.getByName("Single Box").getCurrentValue()
bDoubleBox = oForm.getByName("Double Box").getCurrentValue()
bFoam = oForm.getByName("Foam").getCurrentValue()
bLabels = oForm.getByName("Labels").getCurrentValue()
Rem Initial shipping price
dBaseShipping = 0.00
Rem Add shipping if item selected
if bBubbleWrap Then
dBaseShipping = dBaseShipping + 0.25
End If
if bSingleBox Then
dBaseShipping = dBaseShipping + 0.75
End If
if bDoubleBox Then
dBaseShipping = dBaseShipping + 1.25
End If
if bFoam Then
dBaseShipping = dBaseShipping + 0.45
End If
if bLabels Then
dBaseShipping = dBaseShipping + 0.25
End If
Rem Obtain and update Shipping Cost field
oColumns = oForm.getColumns()
oColumns.getByName("Shipping Cost").updateDouble(dBaseShipping)
End Sub
This was kept very simple because as you stated you have no knowledge in this area. You can see the amounts applied. Those need to be changed accordingly.
Sample-------- ReelToReelModified.odb
There certainly may be better methods to accomplish what is needed but have no real idea what is to be accomplished and certainly no details were provided. This may well have been done without macros by using a secondary table, saving certain data and using SQL to produce totals.
Finally, LO documentation (including some on macros) can be found here → LibreOffice Base Handbook.