FrymanTCU
05-27-2008, 08:08 AM
Ok I have a form that runs a search function to pull in selected records to a subform. Then on the subform I have a cmdButton that is going to modify the selected record. But I wanted to add comments to the record so I created a seperat form that is basically just a text box with a OK and Cancel button. But I need to set the Audit reason, AudRsn to different text depending on which button they click. I have tried this a couple different ways but I keep getting an error message. I'm sure the mistake is something small so if anyone can help or point me to a good article on public variable/strings I would be very greatful.
Thanks,
Rich
Search Main Form
Public Sub cmdAccptInError_DblClick(Cancel As Integer)
Dim AudRsn As String
CallingAccptError AudRsn
DoCmd.OpenForm "Audit Comments"
End Sub
Public Sub CallingAccptError(AudErrorRsn)
AudErrorRsn = "Accepted in Error"
End Sub
TextBox Form
Private Sub cmdOKmemo_Click()
Dim myComments As String
myComments = " & Me.txtAuditNotes.Text & "
Call MyLogSQL
DoCmd.Close acForm, "Audit Comments"
End Sub
Private Sub MyLogSQL()
Dim mySQL As String
mySQL = "UPDATE Log SET AuditReason = '" & AudRsn & "' , AuditComments = '" & [Forms]![Audit Comments]![txtAuditNotes].Value & "' WHERE " _
& "UniqueID = " & [Forms]![RTS Audit]![RTS AuditSubform]![UniqueID] & " ;"
DoCmd.RunSQL mySQL
MsgBox "Log file has been Updated."
mySQL = vbNullString
End Sub
Thanks,
Rich
Search Main Form
Public Sub cmdAccptInError_DblClick(Cancel As Integer)
Dim AudRsn As String
CallingAccptError AudRsn
DoCmd.OpenForm "Audit Comments"
End Sub
Public Sub CallingAccptError(AudErrorRsn)
AudErrorRsn = "Accepted in Error"
End Sub
TextBox Form
Private Sub cmdOKmemo_Click()
Dim myComments As String
myComments = " & Me.txtAuditNotes.Text & "
Call MyLogSQL
DoCmd.Close acForm, "Audit Comments"
End Sub
Private Sub MyLogSQL()
Dim mySQL As String
mySQL = "UPDATE Log SET AuditReason = '" & AudRsn & "' , AuditComments = '" & [Forms]![Audit Comments]![txtAuditNotes].Value & "' WHERE " _
& "UniqueID = " & [Forms]![RTS Audit]![RTS AuditSubform]![UniqueID] & " ;"
DoCmd.RunSQL mySQL
MsgBox "Log file has been Updated."
mySQL = vbNullString
End Sub