VBA Issues

R

requeth

Hello, I am having issues with the following code. Issues are:
1. My insert statement does not insert the data into my table, though
it did before I started programming in the form logic after it.
2. In my messagebox asking "Will it be for the same user?" no matter
if I hit yes or no the vbYes statement runs.

Any ideas what I am doing wrong here? I did add the tableopen, table
save, and table close after the insert statement stopped working, so
if that is incorrect it was after the fact.

Thanks!

Option Compare Database
Public Declare Function apiGetUserName Lib "advapi32.dll" Alias
"GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Function PaperAuditInsert() As String
Dim sqlInsertStatement As String
Dim lngLen As Long, lngX As Long
Dim strUserName As String
Dim v_user As String
Dim spctnamesave As String
Dim spctfxsave As String

strUserName = String$(254, 0)
lngLen = 255
lngX = apiGetUserName(strUserName, lngLen)
If lngX <> 0 Then
GetUserName = Left$(strUserName, lngLen - 1)
Else
GetUserName = ""
End If
v_user = GetUserName
DoCmd.OpenTable "PAPERAUDIT_TABLE", acViewNormal, acEdit
sqlInsertStatement = "Insert into PAPERAUDIT_TABLE([PA_SPCT_FX],
[PA_QA_FX],[PA_DCN],[PA_SPCT_NAME]," _
& "[PA_AUDIT_DATE]," _
& "[PA_AUDIT_TIME],[PA_TID],[PA_APPLICANT_NAME],[PA_SUBMIT_REASON],
[PA_REQ1],[PA_REQ2],[PA_REQ3]," _
& "[PA_REQ4],[PA_REQ5]," _
& "[PA_REQ6],[PA_REQ7],[PA_REQ_PE1],[PA_REQ_PE2],[PA_REQ_PE3],
[PA_REQ_PE4],[PA_REQ_PE5],[PA_REQ_PE6]," _
& "[PA_REQ_PE7]," _
& "[PA_REQ_COMM1],[PA_REQ_COMM2],[PA_REQ_COMM3],[PA_REQ_COMM4],
[PA_REQ_COMM5],[PA_REQ_COMM6]," _
& "[PA_REQ_COMM7])" _
& "Values('" & [Forms]![PAPER_AUDIT]![spctid] & "','" & v_user & "','"
& [Forms]![PAPER_AUDIT]![dcn] & "'," _
& "'" & [Forms]![PAPER_AUDIT]![spctname] & "','" & [Forms]!
[PAPER_AUDIT]![auditdate] & "'," _
& "'" & [Forms]![PAPER_AUDIT]![timeaudit] & "','" & [Forms]!
[PAPER_AUDIT]![trackingid] & "'," _
& "'" & [Forms]![PAPER_AUDIT]![appname] & "','" & [Forms]!
[PAPER_AUDIT]![submitbox] & "'," _
& "'" & [Forms]![PAPER_AUDIT]![p_avail1] & "','" & [Forms]!
[PAPER_AUDIT]![p_avail2] & "'" _
& ",'" & [Forms]![PAPER_AUDIT]![p_avail3] & "','" & [Forms]!
[PAPER_AUDIT]![p_avail4] & "'," _
& "'" & [Forms]![PAPER_AUDIT]![p_avail5] & "','" & [Forms]!
[PAPER_AUDIT]![p_avail6] & "'," _
& "'" & [Forms]![PAPER_AUDIT]![p_avail7] & "'," _
& "'" & [Forms]![PAPER_AUDIT]![p_e1] & "','" & [Forms]![PAPER_AUDIT]!
[p_e2] & "'," _
& "'" & [Forms]![PAPER_AUDIT]![p_e3] & "','" & [Forms]![PAPER_AUDIT]!
[p_e4] & "'," _
& "'" & [Forms]![PAPER_AUDIT]![p_e5] & "','" & [Forms]![PAPER_AUDIT]!
[p_e6] & "'," _
& "'" & [Forms]![PAPER_AUDIT]![p_e7] & "','" & [Forms]![PAPER_AUDIT]!
[comm1] & "'," _
& "'" & [Forms]![PAPER_AUDIT]![comm2] & "','" & [Forms]![PAPER_AUDIT]!
[comm3] & "'," _
& "'" & [Forms]![PAPER_AUDIT]![comm4] & "','" & [Forms]![PAPER_AUDIT]!
[comm5] & "'," _
& "'" & [Forms]![PAPER_AUDIT]![comm6] & "','" & [Forms]![PAPER_AUDIT]!
[comm7] & "')"

DoCmd.SetWarnings False
DoCmd.RunSQL sqlInsertStatement
MsgBox "Statement should have run."
DoCmd.SetWarnings True
DoCmd.Save acTable, "PAPERAUDIT_TABLE"
DoCmd.Close acTable, "PAPERAUDIT_TABLE", acSaveYes


MsgBox "Would you like to fill this form out again?", vbYesNo
If vbYes Then MsgBox "Will it be for the same user?", vbYesNo
If vbYes Then
spctnamesave = Forms!PAPER_AUDIT!spctname
spctfxsave = Forms!PAPER_AUDIT!spctid
'MsgBox spctfxsave
'MsgBox spctnamesave
DoCmd.Close acForm, "PAPER_AUDIT", acSaveNo
DoCmd.OpenForm "PAPER_AUDIT"
Forms!PAPER_AUDIT!spctname = spctnamesave
Forms!PAPER_AUDIT!spctid = spctfxsave
ElseIf vbNo Then
DoCmd.Close acForm, "PAPER_AUDIT", acSaveNo
DoCmd.OpenForm "PAPER_AUDIT"
Else
DoCmd.Close acForm, PAPER_AUDIT, acSaveNo
DoCmd.OpenForm mainmenu
End If
End Function
 
R

requeth

I solved problem number 2 by changing my if statements to:
MsgBox "Would you like to fill this form out again?", vbYesNo
If vbYes Then MsgBox "Will it be for the same user?", vbYesNo
If vbYes Then
spctnamesave = Forms!PAPER_AUDIT!spctname
spctfxsave = Forms!PAPER_AUDIT!spctid
'MsgBox spctfxsave
'MsgBox spctnamesave
DoCmd.Close acForm, "PAPER_AUDIT", acSaveNo
DoCmd.OpenForm "PAPER_AUDIT"
Forms!PAPER_AUDIT!spctname = spctnamesave
Forms!PAPER_AUDIT!spctid = spctfxsave
If vbNo Then
DoCmd.Close acForm, "PAPER_AUDIT", acSaveNo
DoCmd.OpenForm "PAPER_AUDIT"
Else
DoCmd.Close acForm, PAPER_AUDIT, acSaveNo
DoCmd.OpenForm mainmenu
End If
End If

I'm still unable to see why my insert statement does not save,
especially when it worked before.

Hello, I am having issues with the following code. Issues are:
1. My insert statement does not insert the data into my table, though
it did before I started programming in the form logic after it.
2. In my messagebox asking "Will it be for the same user?" no matter
if I hit yes or no the vbYes statement runs.

Any ideas what I am doing wrong here? I did add the tableopen, table
save, and table close after the insert statement stopped working, so
if that is incorrect it was after the fact.

Thanks!

Option Compare Database
Public Declare Function apiGetUserName Lib "advapi32.dll" Alias
"GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Function PaperAuditInsert() As String
Dim sqlInsertStatement As String
Dim lngLen As Long, lngX As Long
Dim strUserName As String
Dim v_user As String
Dim spctnamesave As String
Dim spctfxsave As String

strUserName = String$(254, 0)
lngLen = 255
lngX = apiGetUserName(strUserName, lngLen)
If lngX <> 0 Then
GetUserName = Left$(strUserName, lngLen - 1)
Else
GetUserName = ""
End If
v_user = GetUserName
DoCmd.OpenTable "PAPERAUDIT_TABLE", acViewNormal, acEdit
sqlInsertStatement = "Insert into PAPERAUDIT_TABLE([PA_SPCT_FX],
[PA_QA_FX],[PA_DCN],[PA_SPCT_NAME]," _
& "[PA_AUDIT_DATE]," _
& "[PA_AUDIT_TIME],[PA_TID],[PA_APPLICANT_NAME],[PA_SUBMIT_REASON],
[PA_REQ1],[PA_REQ2],[PA_REQ3]," _
& "[PA_REQ4],[PA_REQ5]," _
& "[PA_REQ6],[PA_REQ7],[PA_REQ_PE1],[PA_REQ_PE2],[PA_REQ_PE3],
[PA_REQ_PE4],[PA_REQ_PE5],[PA_REQ_PE6]," _
& "[PA_REQ_PE7]," _
& "[PA_REQ_COMM1],[PA_REQ_COMM2],[PA_REQ_COMM3],[PA_REQ_COMM4],
[PA_REQ_COMM5],[PA_REQ_COMM6]," _
& "[PA_REQ_COMM7])" _
& "Values('" & [Forms]![PAPER_AUDIT]![spctid] & "','" & v_user & "','"
& [Forms]![PAPER_AUDIT]![dcn] & "'," _
& "'" & [Forms]![PAPER_AUDIT]![spctname] & "','" & [Forms]!
[PAPER_AUDIT]![auditdate] & "'," _
& "'" & [Forms]![PAPER_AUDIT]![timeaudit] & "','" & [Forms]!
[PAPER_AUDIT]![trackingid] & "'," _
& "'" & [Forms]![PAPER_AUDIT]![appname] & "','" & [Forms]!
[PAPER_AUDIT]![submitbox] & "'," _
& "'" & [Forms]![PAPER_AUDIT]![p_avail1] & "','" & [Forms]!
[PAPER_AUDIT]![p_avail2] & "'" _
& ",'" & [Forms]![PAPER_AUDIT]![p_avail3] & "','" & [Forms]!
[PAPER_AUDIT]![p_avail4] & "'," _
& "'" & [Forms]![PAPER_AUDIT]![p_avail5] & "','" & [Forms]!
[PAPER_AUDIT]![p_avail6] & "'," _
& "'" & [Forms]![PAPER_AUDIT]![p_avail7] & "'," _
& "'" & [Forms]![PAPER_AUDIT]![p_e1] & "','" & [Forms]![PAPER_AUDIT]!
[p_e2] & "'," _
& "'" & [Forms]![PAPER_AUDIT]![p_e3] & "','" & [Forms]![PAPER_AUDIT]!
[p_e4] & "'," _
& "'" & [Forms]![PAPER_AUDIT]![p_e5] & "','" & [Forms]![PAPER_AUDIT]!
[p_e6] & "'," _
& "'" & [Forms]![PAPER_AUDIT]![p_e7] & "','" & [Forms]![PAPER_AUDIT]!
[comm1] & "'," _
& "'" & [Forms]![PAPER_AUDIT]![comm2] & "','" & [Forms]![PAPER_AUDIT]!
[comm3] & "'," _
& "'" & [Forms]![PAPER_AUDIT]![comm4] & "','" & [Forms]![PAPER_AUDIT]!
[comm5] & "'," _
& "'" & [Forms]![PAPER_AUDIT]![comm6] & "','" & [Forms]![PAPER_AUDIT]!
[comm7] & "')"

DoCmd.SetWarnings False
DoCmd.RunSQL sqlInsertStatement
MsgBox "Statement should have run."
DoCmd.SetWarnings True
DoCmd.Save acTable, "PAPERAUDIT_TABLE"
DoCmd.Close acTable, "PAPERAUDIT_TABLE", acSaveYes

MsgBox "Would you like to fill this form out again?", vbYesNo
If vbYes Then MsgBox "Will it be for the same user?", vbYesNo
If vbYes Then
spctnamesave = Forms!PAPER_AUDIT!spctname
spctfxsave = Forms!PAPER_AUDIT!spctid
'MsgBox spctfxsave
'MsgBox spctnamesave
DoCmd.Close acForm, "PAPER_AUDIT", acSaveNo
DoCmd.OpenForm "PAPER_AUDIT"
Forms!PAPER_AUDIT!spctname = spctnamesave
Forms!PAPER_AUDIT!spctid = spctfxsave
ElseIf vbNo Then
DoCmd.Close acForm, "PAPER_AUDIT", acSaveNo
DoCmd.OpenForm "PAPER_AUDIT"
Else
DoCmd.Close acForm, PAPER_AUDIT, acSaveNo
DoCmd.OpenForm mainmenu
End If
End Function
 
R

requeth

Nevermind, I didnt solve issue 2. I'm only able to execute my first if
statements, I cant get any else statements to function unless I stop
nesting them, and I really need that nesting.

I solved problem number 2 by changing my if statements to:
MsgBox "Would you like to fill this form out again?", vbYesNo
If vbYes Then MsgBox "Will it be for the same user?", vbYesNo
If vbYes Then
spctnamesave = Forms!PAPER_AUDIT!spctname
spctfxsave = Forms!PAPER_AUDIT!spctid
'MsgBox spctfxsave
'MsgBox spctnamesave
DoCmd.Close acForm, "PAPER_AUDIT", acSaveNo
DoCmd.OpenForm "PAPER_AUDIT"
Forms!PAPER_AUDIT!spctname = spctnamesave
Forms!PAPER_AUDIT!spctid = spctfxsave
If vbNo Then
DoCmd.Close acForm, "PAPER_AUDIT", acSaveNo
DoCmd.OpenForm "PAPER_AUDIT"
Else
DoCmd.Close acForm, PAPER_AUDIT, acSaveNo
DoCmd.OpenForm mainmenu
End If
End If

I'm still unable to see why my insert statement does not save,
especially when it worked before.

Hello, I am having issues with the following code. Issues are:
1. My insert statement does not insert the data into my table, though
it did before I started programming in the form logic after it.
2. In my messagebox asking "Will it be for the same user?" no matter
if I hit yes or no the vbYes statement runs.
Any ideas what I am doing wrong here? I did add the tableopen, table
save, and table close after the insert statement stopped working, so
if that is incorrect it was after the fact.

Option Compare Database
Public Declare Function apiGetUserName Lib "advapi32.dll" Alias
"GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Function PaperAuditInsert() As String
Dim sqlInsertStatement As String
Dim lngLen As Long, lngX As Long
Dim strUserName As String
Dim v_user As String
Dim spctnamesave As String
Dim spctfxsave As String
strUserName = String$(254, 0)
lngLen = 255
lngX = apiGetUserName(strUserName, lngLen)
If lngX <> 0 Then
GetUserName = Left$(strUserName, lngLen - 1)
Else
GetUserName = ""
End If
v_user = GetUserName
DoCmd.OpenTable "PAPERAUDIT_TABLE", acViewNormal, acEdit
sqlInsertStatement = "Insert into PAPERAUDIT_TABLE([PA_SPCT_FX],
[PA_QA_FX],[PA_DCN],[PA_SPCT_NAME]," _
& "[PA_AUDIT_DATE]," _
& "[PA_AUDIT_TIME],[PA_TID],[PA_APPLICANT_NAME],[PA_SUBMIT_REASON],
[PA_REQ1],[PA_REQ2],[PA_REQ3]," _
& "[PA_REQ4],[PA_REQ5]," _
& "[PA_REQ6],[PA_REQ7],[PA_REQ_PE1],[PA_REQ_PE2],[PA_REQ_PE3],
[PA_REQ_PE4],[PA_REQ_PE5],[PA_REQ_PE6]," _
& "[PA_REQ_PE7]," _
& "[PA_REQ_COMM1],[PA_REQ_COMM2],[PA_REQ_COMM3],[PA_REQ_COMM4],
[PA_REQ_COMM5],[PA_REQ_COMM6]," _
& "[PA_REQ_COMM7])" _
& "Values('" & [Forms]![PAPER_AUDIT]![spctid] & "','" & v_user & "','"
& [Forms]![PAPER_AUDIT]![dcn] & "'," _
& "'" & [Forms]![PAPER_AUDIT]![spctname] & "','" & [Forms]!
[PAPER_AUDIT]![auditdate] & "'," _
& "'" & [Forms]![PAPER_AUDIT]![timeaudit] & "','" & [Forms]!
[PAPER_AUDIT]![trackingid] & "'," _
& "'" & [Forms]![PAPER_AUDIT]![appname] & "','" & [Forms]!
[PAPER_AUDIT]![submitbox] & "'," _
& "'" & [Forms]![PAPER_AUDIT]![p_avail1] & "','" & [Forms]!
[PAPER_AUDIT]![p_avail2] & "'" _
& ",'" & [Forms]![PAPER_AUDIT]![p_avail3] & "','" & [Forms]!
[PAPER_AUDIT]![p_avail4] & "'," _
& "'" & [Forms]![PAPER_AUDIT]![p_avail5] & "','" & [Forms]!
[PAPER_AUDIT]![p_avail6] & "'," _
& "'" & [Forms]![PAPER_AUDIT]![p_avail7] & "'," _
& "'" & [Forms]![PAPER_AUDIT]![p_e1] & "','" & [Forms]![PAPER_AUDIT]!
[p_e2] & "'," _
& "'" & [Forms]![PAPER_AUDIT]![p_e3] & "','" & [Forms]![PAPER_AUDIT]!
[p_e4] & "'," _
& "'" & [Forms]![PAPER_AUDIT]![p_e5] & "','" & [Forms]![PAPER_AUDIT]!
[p_e6] & "'," _
& "'" & [Forms]![PAPER_AUDIT]![p_e7] & "','" & [Forms]![PAPER_AUDIT]!
[comm1] & "'," _
& "'" & [Forms]![PAPER_AUDIT]![comm2] & "','" & [Forms]![PAPER_AUDIT]!
[comm3] & "'," _
& "'" & [Forms]![PAPER_AUDIT]![comm4] & "','" & [Forms]![PAPER_AUDIT]!
[comm5] & "'," _
& "'" & [Forms]![PAPER_AUDIT]![comm6] & "','" & [Forms]![PAPER_AUDIT]!
[comm7] & "')"
DoCmd.SetWarnings False
DoCmd.RunSQL sqlInsertStatement
MsgBox "Statement should have run."
DoCmd.SetWarnings True
DoCmd.Save acTable, "PAPERAUDIT_TABLE"
DoCmd.Close acTable, "PAPERAUDIT_TABLE", acSaveYes
MsgBox "Would you like to fill this form out again?", vbYesNo
If vbYes Then MsgBox "Will it be for the same user?", vbYesNo
If vbYes Then
spctnamesave = Forms!PAPER_AUDIT!spctname
spctfxsave = Forms!PAPER_AUDIT!spctid
'MsgBox spctfxsave
'MsgBox spctnamesave
DoCmd.Close acForm, "PAPER_AUDIT", acSaveNo
DoCmd.OpenForm "PAPER_AUDIT"
Forms!PAPER_AUDIT!spctname = spctnamesave
Forms!PAPER_AUDIT!spctid = spctfxsave
ElseIf vbNo Then
DoCmd.Close acForm, "PAPER_AUDIT", acSaveNo
DoCmd.OpenForm "PAPER_AUDIT"
Else
DoCmd.Close acForm, PAPER_AUDIT, acSaveNo
DoCmd.OpenForm mainmenu
End If
End Function- Hide quoted text -

- Show quoted text -
 
R

requeth

Ok. NOW I've solved issue 2. It helps when you write in VBA. ;)
Updated code for that is below. Still cant figure out the insert
statement, but I will keep trying. If anyone spots something please
notify me.

spctnamesave = Forms!PAPER_AUDIT!spctname
spctfxsave = Forms!PAPER_AUDIT!spctid

If MsgBox("Would you like to fill this form out again?", vbYesNo) =
vbYes Then
'DoCmd.Close acForm, "PAPER_AUDIT", acSaveNo
' DoCmd.OpenForm "PAPER_AUDIT"
If MsgBox("Will it be for the same user?", vbYesNo) = vbYes Then
'MsgBox spctfxsave
'MsgBox spctnamesave
DoCmd.Close acForm, "PAPER_AUDIT", acSaveNo
DoCmd.OpenForm "PAPER_AUDIT"
Forms!PAPER_AUDIT!spctname = spctnamesave
Forms!PAPER_AUDIT!spctid = spctfxsave
ElseIf vbNo Then
DoCmd.Close acForm, "PAPER_AUDIT", acSaveNo
DoCmd.OpenForm "PAPER_AUDIT"
End If
Else
DoCmd.Close acForm, "PAPER_AUDIT", acSaveNo
DoCmd.OpenForm "mainmenu"
End If


Nevermind, I didnt solve issue 2. I'm only able to execute my first if
statements, I cant get any else statements to function unless I stop
nesting them, and I really need that nesting.

I solved problem number 2 by changing my if statements to:
MsgBox "Would you like to fill this form out again?", vbYesNo
If vbYes Then MsgBox "Will it be for the same user?", vbYesNo
If vbYes Then
spctnamesave = Forms!PAPER_AUDIT!spctname
spctfxsave = Forms!PAPER_AUDIT!spctid
'MsgBox spctfxsave
'MsgBox spctnamesave
DoCmd.Close acForm, "PAPER_AUDIT", acSaveNo
DoCmd.OpenForm "PAPER_AUDIT"
Forms!PAPER_AUDIT!spctname = spctnamesave
Forms!PAPER_AUDIT!spctid = spctfxsave
If vbNo Then
DoCmd.Close acForm, "PAPER_AUDIT", acSaveNo
DoCmd.OpenForm "PAPER_AUDIT"
Else
DoCmd.Close acForm, PAPER_AUDIT, acSaveNo
DoCmd.OpenForm mainmenu
End If
End If
I'm still unable to see why my insert statement does not save,
especially when it worked before.
Hello, I am having issues with the following code. Issues are:
1. My insert statement does not insert the data into my table, though
it did before I started programming in the form logic after it.
2. In my messagebox asking "Will it be for the same user?" no matter
if I hit yes or no the vbYes statement runs.
Any ideas what I am doing wrong here? I did add the tableopen, table
save, and table close after the insert statement stopped working, so
if that is incorrect it was after the fact.
Thanks!
Option Compare Database
Public Declare Function apiGetUserName Lib "advapi32.dll" Alias
"GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Function PaperAuditInsert() As String
Dim sqlInsertStatement As String
Dim lngLen As Long, lngX As Long
Dim strUserName As String
Dim v_user As String
Dim spctnamesave As String
Dim spctfxsave As String
strUserName = String$(254, 0)
lngLen = 255
lngX = apiGetUserName(strUserName, lngLen)
If lngX <> 0 Then
GetUserName = Left$(strUserName, lngLen - 1)
Else
GetUserName = ""
End If
v_user = GetUserName
DoCmd.OpenTable "PAPERAUDIT_TABLE", acViewNormal, acEdit
sqlInsertStatement = "Insert into PAPERAUDIT_TABLE([PA_SPCT_FX],
[PA_QA_FX],[PA_DCN],[PA_SPCT_NAME]," _
& "[PA_AUDIT_DATE]," _
& "[PA_AUDIT_TIME],[PA_TID],[PA_APPLICANT_NAME],[PA_SUBMIT_REASON],
[PA_REQ1],[PA_REQ2],[PA_REQ3]," _
& "[PA_REQ4],[PA_REQ5]," _
& "[PA_REQ6],[PA_REQ7],[PA_REQ_PE1],[PA_REQ_PE2],[PA_REQ_PE3],
[PA_REQ_PE4],[PA_REQ_PE5],[PA_REQ_PE6]," _
& "[PA_REQ_PE7]," _
& "[PA_REQ_COMM1],[PA_REQ_COMM2],[PA_REQ_COMM3],[PA_REQ_COMM4],
[PA_REQ_COMM5],[PA_REQ_COMM6]," _
& "[PA_REQ_COMM7])" _
& "Values('" & [Forms]![PAPER_AUDIT]![spctid] & "','" & v_user & "','"
& [Forms]![PAPER_AUDIT]![dcn] & "'," _
& "'" & [Forms]![PAPER_AUDIT]![spctname] & "','" & [Forms]!
[PAPER_AUDIT]![auditdate] & "'," _
& "'" & [Forms]![PAPER_AUDIT]![timeaudit] & "','" & [Forms]!
[PAPER_AUDIT]![trackingid] & "'," _
& "'" & [Forms]![PAPER_AUDIT]![appname] & "','" & [Forms]!
[PAPER_AUDIT]![submitbox] & "'," _
& "'" & [Forms]![PAPER_AUDIT]![p_avail1] & "','" & [Forms]!
[PAPER_AUDIT]![p_avail2] & "'" _
& ",'" & [Forms]![PAPER_AUDIT]![p_avail3] & "','" & [Forms]!
[PAPER_AUDIT]![p_avail4] & "'," _
& "'" & [Forms]![PAPER_AUDIT]![p_avail5] & "','" & [Forms]!
[PAPER_AUDIT]![p_avail6] & "'," _
& "'" & [Forms]![PAPER_AUDIT]![p_avail7] & "'," _
& "'" & [Forms]![PAPER_AUDIT]![p_e1] & "','" & [Forms]![PAPER_AUDIT]!
[p_e2] & "'," _
& "'" & [Forms]![PAPER_AUDIT]![p_e3] & "','" & [Forms]![PAPER_AUDIT]!
[p_e4] & "'," _
& "'" & [Forms]![PAPER_AUDIT]![p_e5] & "','" & [Forms]![PAPER_AUDIT]!
[p_e6] & "'," _
& "'" & [Forms]![PAPER_AUDIT]![p_e7] & "','" & [Forms]![PAPER_AUDIT]!
[comm1] & "'," _
& "'" & [Forms]![PAPER_AUDIT]![comm2] & "','" & [Forms]![PAPER_AUDIT]!
[comm3] & "'," _
& "'" & [Forms]![PAPER_AUDIT]![comm4] & "','" & [Forms]![PAPER_AUDIT]!
[comm5] & "'," _
& "'" & [Forms]![PAPER_AUDIT]![comm6] & "','" & [Forms]![PAPER_AUDIT]!
[comm7] & "')"
DoCmd.SetWarnings False
DoCmd.RunSQL sqlInsertStatement
MsgBox "Statement should have run."
DoCmd.SetWarnings True
DoCmd.Save acTable, "PAPERAUDIT_TABLE"
DoCmd.Close acTable, "PAPERAUDIT_TABLE", acSaveYes
MsgBox "Would you like to fill this form out again?", vbYesNo
If vbYes Then MsgBox "Will it be for the same user?", vbYesNo
If vbYes Then
spctnamesave = Forms!PAPER_AUDIT!spctname
spctfxsave = Forms!PAPER_AUDIT!spctid
'MsgBox spctfxsave
'MsgBox spctnamesave
DoCmd.Close acForm, "PAPER_AUDIT", acSaveNo
DoCmd.OpenForm "PAPER_AUDIT"
Forms!PAPER_AUDIT!spctname = spctnamesave
Forms!PAPER_AUDIT!spctid = spctfxsave
ElseIf vbNo Then
DoCmd.Close acForm, "PAPER_AUDIT", acSaveNo
DoCmd.OpenForm "PAPER_AUDIT"
Else
DoCmd.Close acForm, PAPER_AUDIT, acSaveNo
DoCmd.OpenForm mainmenu
End If
End Function- Hide quoted text -
- Show quoted text -- Hide quoted text -

- Show quoted text -
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top