Hi everyone,
Hope you doing fine.
below is working code for message box, i want to amend the else portion of message box when VB Yes than it has to check whether the exchange rate is exist or not if exist then it should open the frmRecordExhRates with its values and dont create new entry, in below code its open with currency and date value with rate field blank but there is already rate on this date, i want him to populate that rate in fields of frmRecordExhRates when its open by vb Yes in else part of if condition.
Hope you doing fine.
below is working code for message box, i want to amend the else portion of message box when VB Yes than it has to check whether the exchange rate is exist or not if exist then it should open the frmRecordExhRates with its values and dont create new entry, in below code its open with currency and date value with rate field blank but there is already rate on this date, i want him to populate that rate in fields of frmRecordExhRates when its open by vb Yes in else part of if condition.
Code:
Private Sub ExchangeRate_BeforeUpdate(Cancel As Integer)
Dim ERate As Integer
Dim VBAnsw As String
Dim sArgs As String
sArgs = Me.Currency & ";" & Me.TransactionDate
ERate = Nz(DLookup("[Rate]", "tblExchangeRates", "[Currency] = '" & Me.Currency & "' And [ExhDate] = #" & Me.TransactionDate & "#"), 0)
If Me.ExchangeRate <> ERate Then
VBAnsw = MsgBox("This rate is not found in exchange rate records!" & vbCrLf & vbCrLf & _
"Do you want to keep the rate limited to this transaction Only?", vbYesNo, "Warning")
If VBAnsw = vbNo Then
Cancel = True
Else
VBAnsw = MsgBox("You have changed this currency's exchange rate" & vbCrLf & vbCrLf & _
"Would you like system to change the rate for all transactions on this date?", vbYesNo, "Warning")
If VBAnsw = vbYes Then
DoCmd.OpenForm "frmRecordExhRates", acNormal, , , acFormAdd, acDialog, sArgs
Debug.Print sArgs
End If
End If
End If
End Sub