0

I recently split my ms access database into a front, and back end. I didn't know that the data macros that were on the table wouldn't be able to work anymore. I was wondering if there is any way to convert these to vba.

if IsNull([prmQuoteID])
    RaiseError
        Error Number 10
        Error Description Please specify quote details.
end if
RunDataMacro
    Macro Name Quotes.GetNextQuoteNumber
SetLocalVar
    Name varNextQuoteNumber
    Expression = [ReturnVars]![retNextQuoteNumber]
RunDataMacro
    Macro Name Quotes.UpdateQuoteTotal 
    parameters
        prmQuoteId = [prmQuoteId]
if [varNextQuoteNumber]=0
    RaiseError
        Error Number 20
        Error Description Unable to retrieve next quote number!
stopmacro
end if
Look Up A Record In SELECT Quotes.ID, Quotes.StatusID, Quotes.QuoteNumber, Quotes.Submitted FROM Quotes; 
    Where Condition  = [ID]=[prmQuoteID]
    if [StatusID]>=10
        RaiseError
            Error 30
            Error Description Quote has already been marked submitted.
    End If
    Edit Record
        SetField
            Name StatusId
            Value = 10
        SetField
            Name QuoteNumber
            Value = [varNextQuoteNumber]
        SetField
            Name Submitted
            Value = Date()

Example of Data Macro Data Macro Photo of above code

It connects to an form on click embedded macro in the front end database On click embedded macro

OnError
    go to Macro Name
    ErrorHandler
SetTempVar
    Name YesNoMessage
    Expression = "Quote cannot be changed once it is submitted."
SetTempVar
    Name YesNoMessage2
    Expression = ""Do you want to continue?""
OpenForm
    Form Name YesNoAlert
    View Form
    Window Mode Dialog
If [TempVars]![YesNoResponse]=False
    stopmacro
End If
RunMenuCommand
    command saveRecord
RunDataMacro
    Macro Name Quotes.Submit
    Parameters
        prmQuoteId = [txtID]
RefreshRecord
RunMacro
    Macro Name SetFromState
SetTempVar
    Name AlertMessage
    Expression "Quote #" & [txtQuoteNumber] & " is now submitted for approval."
OpenForm
    Form Name Okalert
    View Form
    Window Mode Dialog
Submacro: ErrorHandler
    RunMacro
        Macro Name Utilities.ErrorAlert
End Submacro

I was wondering what the best way to convert these would be and still have them work for someone with limited VBA knowledge.

June7
  • 19,874
  • 8
  • 24
  • 34

0 Answers0