Hi, Thank you for your kind help, the timestamp works great, but the 2nd question still having problem. I meant to move the completed record to other table, so the record also need to be deleted from the original file. Thanks again.
1. If "Text18" text string contains more than just "COMPLETED”, it won’t get transferred to archive table, seems that it looks for "COMPLETED" only. It should be moved to archive table as long as COMPLETED is typed in.
How to concatenate for longer text string? I thought InStr will do the job.
2. the record fields is up to 50 fields, is there a simple way to include all fields instead of concatenate every fields?
3. is there a move command for the whole record instead of insert into & delete statement? If not, do I simply add delete statement like you did for insert into statement? For example:
dim sSql as string
sSql = "INSERT INTO table2 ( fldDate, fldNum, fldText ) " & _ "VALUES (#" & Forms![MyForm]!txtDate & "#," & Forms![MyForm]!txtNum & _ ",'" & Forms![MyForm]!txtText & "');"
sSql = "delete from table1 ( fldDate, fldNum, fldText ) " & _ " (#" & Forms![MyForm]!txtDate & "#," & Forms![MyForm]!txtNum & _ ",'" & Forms![MyForm]!txtText & "');"
docmd.runsql ssql
I’m having some problem with the following code
____________________________________________________________
Option Compare Database
Private Sub Text18_AfterUpdate()
Dim i As Integer
Dim sSql As String
For i = 13 To 50
If IsNull(Me("field" & i).Value) Then
Me!Text18.Value = Me!Text18.Value & " " & Now
Me("field" & i).Value = Me!Text18.Value
Exit For
End If
Next i
If InStr(Me!Text18.Value, "completed") = 1 Then
sSql = "INSERT INTO Completed_FY04 (StartDate, Division, SRMNo, Status) " & _
"VALUES (#" & Forms![certStatus]!StartDate & "#," & Forms![certStatus]!Division & _
",'" & Forms![certStatus]!SRMNo & "'" & _
",'" & Forms![certStatus]!Status & "');"
DoCmd.RunSQL sSql
End If
End Sub
____________________________________________________
RoyVidar (Instructor) Apr 27, 2004
Hi!
#1Adding a timestamp to a control:Me!txtControl.Value = NowShould it alredy contain something, you could try concatination:Me!txtControl.Value = Me!txtControl.Value & " Tmstmp: " & NowEvent - hmmm - if it's every time a change is saved, use the before update event of the form (fires whenever a save is performed)
#2Perhaps the before update/after update event of the form, run some sql:
dim sSql as string
sSql = "INSERT INTO table2 ( fldDate, fldNum, fldText ) " & _ "VALUES (#" & Forms![MyForm]!txtDate & "#," & Forms![MyForm]!txtNum & _ ",'" & Forms![MyForm]!txtText & "');"
docmd.runsql ssql
Is the code supposed to test for the text "completed" within the textbox?
if instr(me!txtBox.Value,"completed")=0 then ' perform the above... -
this sample contains both date, numeric, and text fields, note the delimiters, hash (#) for dates, single quote (') for text, nothing for numerics. - but saving the same data in two tables, isn't encouraged (violates lots of database rules ), it's bound to give future headaches...
1. If "Text18" text string contains more than just "COMPLETED”, it won’t get transferred to archive table, seems that it looks for "COMPLETED" only. It should be moved to archive table as long as COMPLETED is typed in.
How to concatenate for longer text string? I thought InStr will do the job.
2. the record fields is up to 50 fields, is there a simple way to include all fields instead of concatenate every fields?
3. is there a move command for the whole record instead of insert into & delete statement? If not, do I simply add delete statement like you did for insert into statement? For example:
dim sSql as string
sSql = "INSERT INTO table2 ( fldDate, fldNum, fldText ) " & _ "VALUES (#" & Forms![MyForm]!txtDate & "#," & Forms![MyForm]!txtNum & _ ",'" & Forms![MyForm]!txtText & "');"
sSql = "delete from table1 ( fldDate, fldNum, fldText ) " & _ " (#" & Forms![MyForm]!txtDate & "#," & Forms![MyForm]!txtNum & _ ",'" & Forms![MyForm]!txtText & "');"
docmd.runsql ssql
I’m having some problem with the following code
____________________________________________________________
Option Compare Database
Private Sub Text18_AfterUpdate()
Dim i As Integer
Dim sSql As String
For i = 13 To 50
If IsNull(Me("field" & i).Value) Then
Me!Text18.Value = Me!Text18.Value & " " & Now
Me("field" & i).Value = Me!Text18.Value
Exit For
End If
Next i
If InStr(Me!Text18.Value, "completed") = 1 Then
sSql = "INSERT INTO Completed_FY04 (StartDate, Division, SRMNo, Status) " & _
"VALUES (#" & Forms![certStatus]!StartDate & "#," & Forms![certStatus]!Division & _
",'" & Forms![certStatus]!SRMNo & "'" & _
",'" & Forms![certStatus]!Status & "');"
DoCmd.RunSQL sSql
End If
End Sub
____________________________________________________
RoyVidar (Instructor) Apr 27, 2004
Hi!
#1Adding a timestamp to a control:Me!txtControl.Value = NowShould it alredy contain something, you could try concatination:Me!txtControl.Value = Me!txtControl.Value & " Tmstmp: " & NowEvent - hmmm - if it's every time a change is saved, use the before update event of the form (fires whenever a save is performed)
#2Perhaps the before update/after update event of the form, run some sql:
dim sSql as string
sSql = "INSERT INTO table2 ( fldDate, fldNum, fldText ) " & _ "VALUES (#" & Forms![MyForm]!txtDate & "#," & Forms![MyForm]!txtNum & _ ",'" & Forms![MyForm]!txtText & "');"
docmd.runsql ssql
Is the code supposed to test for the text "completed" within the textbox?
if instr(me!txtBox.Value,"completed")=0 then ' perform the above... -
this sample contains both date, numeric, and text fields, note the delimiters, hash (#) for dates, single quote (') for text, nothing for numerics. - but saving the same data in two tables, isn't encouraged (violates lots of database rules ), it's bound to give future headaches...