473,406 Members | 2,377 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Update Record in one Form and Open in another form?

thisisntwally
I've created a button in formA which updates the table in question, but i'd like to have an option to update and open the same record in form2

(different datafields are being entered so i don't think the
Expand|Select|Wrap|Line Numbers
  1. DoCmd.openForm "form2", , , "[field]=" & Me.[field]
approach will work).

Is there anyway i can use the .bookmark property to open the new form?

The primary key is autogenerated on update, but as they're not a part of the input(1) or update(2) forms I'd like to avoid using it if possible
Jun 29 '07 #1
24 5041
FishVal
2,653 Expert 2GB
I've created a button in formA which updates the table in question, but i'd like to have an option to update and open the same record in form2

(different datafields are being entered so i don't think the
Expand|Select|Wrap|Line Numbers
  1. DoCmd.openForm "form2", , , "[field]=" & Me.[field]
approach will work).

Is there anyway i can use the .bookmark property to open the new form?

The primary key is autogenerated on update, but as they're not a part of the input(1) or update(2) forms I'd like to avoid using it if possible
Hi!

First of all there is no any reason why DoCmd.OpenForm will not work here.
You can use any field of Form2 Recordsource in DoCmd.OpenForm WhereCondition argument no matter it is bound or not to any control (certainly PK is preferrable).
If you have any special reason not to show the corresponding field on Form1, you can either hide the control bound to the corresponding field or retrieve it's value from Form1 Recordset.

I don't see any problem at all.
Jul 1 '07 #2
Hi!

First of all there is no any reason why DoCmd.OpenForm will not work here.
You can use any field of Form2 Recordsource in DoCmd.OpenForm WhereCondition argument no matter it is bound or not to any control (certainly PK is preferrable).
If you have any special reason not to show the corresponding field on Form1, you can either hide the control bound to the corresponding field or retrieve it's value from Form1 Recordset.

I don't see any problem at all.
When you say retrieve value from recordset, is that to say i can reference a value not explicitly included in form1, provided its a field on the table? And if so can I reference a key which is autofilled on completion of Form1?
Jul 2 '07 #3
FishVal
2,653 Expert 2GB
When you say retrieve value from recordset, is that to say i can reference a value not explicitly included in form1, provided its a field on the table? And if so can I reference a key which is autofilled on completion of Form1?
Sure.

Something like this (assumed this is in Form1 module), where keyID is the name of PK table field

Expand|Select|Wrap|Line Numbers
  1. Me.Recordset![keyID]
  2.  
Jul 2 '07 #4
Sure.

Something like this (assumed this is in Form1 module), where keyID is the name of PK table field

Expand|Select|Wrap|Line Numbers
  1. Me.Recordset![keyID]
  2.  

Thats the most helpful thing i've gotten yet! You rock.

Expand|Select|Wrap|Line Numbers
  1. Now why does it insist on only applying changes to the First record?
  2.  Dim stDocName As String
  3.     Dim stLinkCriteria As String
  4.  
  5.     stLinkCriteria = "Me.LastModified!key = & Forms![Input Form].txtkey"
  6.     stDocName = "Update"
  7.        DoCmd.openForm stDocName, , , stLinkCriteria
  8.  
Jul 3 '07 #5
FishVal
2,653 Expert 2GB
Thats the most helpful thing i've gotten yet! You rock.

Expand|Select|Wrap|Line Numbers
  1. Now why does it insist on only applying changes to the First record?
  2. Dim stDocName As String
  3. Dim stLinkCriteria As String
  4.  
  5. stLinkCriteria = "Me.LastModified!key = & Forms![Input Form].txtkey"
  6. stDocName = "Update"
  7. DoCmd.openForm stDocName, , , stLinkCriteria
  8.  
???
What is this code supposed to do?
I mean stLinkCriteria which is completely senseless. It should be a WHERE clause for Form_Update Recordsource.

For example

assumed
- the code opening Form_Update is in Form_Input module
- the name of recordsource table/query field you want to filter by is [Field]
- the [Field] is not bound to any control in Form_Input

Expand|Select|Wrap|Line Numbers
  1. stLinkCriteria = "[Field] = " & Me.Recordset![Field]
  2.  
or

Expand|Select|Wrap|Line Numbers
  1. stLinkCriteria = "[Field] = " & Me![Field]
  2.  
if anyway it is bound to Form_Input field named Field.
Jul 3 '07 #6
???
What is this code supposed to do?
I mean stLinkCriteria which is completely senseless. It should be a WHERE clause for Form_Update Recordsource.

For example

assumed
- the code opening Form_Update is in Form_Input module
- the name of recordsource table/query field you want to filter by is [Field]
- the [Field] is not bound to any control in Form_Input

Expand|Select|Wrap|Line Numbers
  1. stLinkCriteria = "[Field] = " & Me.Recordset![Field]
  2.  
or

Expand|Select|Wrap|Line Numbers
  1. stLinkCriteria = "[Field] = " & Me![Field]
  2.  
if anyway it is bound to Form_Input field named Field.
Well while i am quite sure its rather convoluted at this point, its an attempt at opening a newly added record in a new form. it started out as you have above - but checking that again im getting a .(dot) or !operator or invalid parenthesis error...
Jul 5 '07 #7
FishVal
2,653 Expert 2GB
Well while i am quite sure its rather convoluted at this point, its an attempt at opening a newly added record in a new form. it started out as you have above - but checking that again im getting a .(dot) or !operator or invalid parenthesis error...
Post the whole sub which opens form "Update", as it looks so far, just to make sure we are mentioning the same.
BTW be aware that while a record is not saved (pencil mark on the record selector) you can't open it in another form. To save the record use
Expand|Select|Wrap|Line Numbers
  1. DoCmd.RunCommand acCmdSaveRecord
  2.  
anywhere before DoCmd.OpenForm command.
Jul 5 '07 #8
heres the sub ATM. im still getting the same error. I added the save command, and have changed my PK from an Autonumber to number, and its control source to =DMAX("key",[tbl Modifications]) + 1.
not that it produced any results per se.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command85_Click()
  2. On Error GoTo Err_Command85_Click
  3.     With CurrentDb.OpenRecordset("tbl Modifications", dbOpenTable)
  4.         .AddNew
  5.           !Program = Me.txtProgram                         '\
  6.           !Name = Me.cboName                                 '|
  7.           !ObjectClass = Me.cboObjectClass
  8.           !ParentProgram = Me.txtParentProgram
  9.           !Fund = Me.txtfund
  10.           !ReportingEntity = Me.txtReportingEntity
  11.           !PurchaseOrder = Me.txtPurchaseOrder
  12.           !Comments = Me.txtComments
  13.           !AppropriationYear = Me.cboAppropriationYear
  14.           !Site = Me.txtsite
  15.           !DOR = Me.txtDOR
  16.           !FiscalYear = Me.cboFiscalYear                            '|
  17.           !Description = Me.txtdescription                           '|
  18.           !Budget = Me.txtCharge                             '|
  19.           !UpdateDate = Date
  20.           !SSD = Me.txtSSD
  21.           !CertifiedDocument = Me.objRequest
  22.           !BCD = Me.txtBCD
  23.           !FCD = Me.txtFCD
  24.           !Vendor = Me.txtVendor
  25.           !key = Me.txtkey          
  26.         .Update
  27.         .Bookmark = .LastModified        
  28.      End With    
  29.    Dim stDocName As String
  30.     Dim stLinkCriteria As String
  31.  
  32.    stLinkCriteria = "[txtkey]= " & Me![txtkey]
  33.     stDocName = "Update"
  34.     DoCmd.RunCommand acCmdSaveRecord
  35.     DoCmd.openForm stDocName, , , stLinkCriteria    
  36.  
  37.  
  38. Exit_Command85_Click:
  39.     Exit Sub
  40.  
  41. Err_Command85_Click:
  42.     MsgBox Err.Description
  43.     Resume Exit_Command85_Click
  44.  
  45. End Sub
  46.  

edit: I also tried Me.Recordset![txtkey] which had the same result
another edit: stepping through the code, it goes to error on !key = Me....
Jul 5 '07 #9
FishVal
2,653 Expert 2GB
heres the sub ATM. im still getting the same error. I added the save command, and have changed my PK from an Autonumber to number, and its control source to =DMAX("key",[tbl Modifications]) + 1.
not that it produced any results per se.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command85_Click()
  2. On Error GoTo Err_Command85_Click
  3. With CurrentDb.OpenRecordset("tbl Modifications", dbOpenTable)
  4. .AddNew
  5. !Program = Me.txtProgram '\
  6. !Name = Me.cboName '|
  7. !ObjectClass = Me.cboObjectClass
  8. !ParentProgram = Me.txtParentProgram
  9. !Fund = Me.txtfund
  10. !ReportingEntity = Me.txtReportingEntity
  11. !PurchaseOrder = Me.txtPurchaseOrder
  12. !Comments = Me.txtComments
  13. !AppropriationYear = Me.cboAppropriationYear
  14. !Site = Me.txtsite
  15. !DOR = Me.txtDOR
  16. !FiscalYear = Me.cboFiscalYear '|
  17. !Description = Me.txtdescription '|
  18. !Budget = Me.txtCharge '|
  19. !UpdateDate = Date
  20. !SSD = Me.txtSSD
  21. !CertifiedDocument = Me.objRequest
  22. !BCD = Me.txtBCD
  23. !FCD = Me.txtFCD
  24. !Vendor = Me.txtVendor
  25. !key = Me.txtkey 
  26. .Update
  27. .Bookmark = .LastModified 
  28. End With 
  29. Dim stDocName As String
  30. Dim stLinkCriteria As String
  31.  
  32. stLinkCriteria = "[txtkey]= " & Me![txtkey]
  33. stDocName = "Update"
  34. DoCmd.RunCommand acCmdSaveRecord
  35. DoCmd.openForm stDocName, , , stLinkCriteria 
  36.  
  37.  
  38. Exit_Command85_Click:
  39. Exit Sub
  40.  
  41. Err_Command85_Click:
  42. MsgBox Err.Description
  43. Resume Exit_Command85_Click
  44.  
  45. End Sub
  46.  

edit: I also tried Me.Recordset![txtkey] which had the same result
another edit: stepping through the code, it goes to error on !key = Me....
Ok. Its much more cleare now where the legs are growing from.
The problem is so far in record update. The syntax seems to be Ok. Just a silly question concerning this: is the form bound to [tbl Modifications]?
The next one: is form "Update" bound to [tbl Modifications]?
Jul 6 '07 #10
Ok. Its much more cleare now where the legs are growing from.
The problem is so far in record update. The syntax seems to be Ok. Just a silly question concerning this: is the form bound to [tbl Modifications]?
The next one: is form "Update" bound to [tbl Modifications]?
Both tables are indeed bound to [tbl Modifications]. There has been some who question my logic (i don't believe its all that ab-normal hehheh) but for user simplicity's sake im rather stubborn about having two forms. I do have a functioning tabbed form which combines the two, so I could get to work on some other functions in the database, but I hate the d@mn thing.
Jul 6 '07 #11
Both tables are indeed bound to [tbl Modifications]. There has been some who question my logic (i don't believe its all that ab-normal hehheh) but for user simplicity's sake im rather stubborn about having two forms. I do have a functioning tabbed form which combines the two, so I could get to work on some other functions in the database, but I hate the d@mn thing.
speaking of, i went ahead and changed the control source for "txtkey" on the all-inclusive tabbed form to =DMAX("key",[tbl Modifications]) + 1, and now have the same problem. (as it used to be autonumber and there was no need to reference the key on the combined form, this was never an issue).

that being said, it seems to me as though there is a problem with my Dmax syntax...
Jul 6 '07 #12
hoookay, Got some of this worked out, i just changed the update spec to Dmax and voila! (well at first i forgot to change the control source...and maybe there was something else...)

that being said, the second form still insists on updating the first record. It is of course friendly enough to change the key value to corrispond with the first form - thus creating duplicates and leading me to believe the problem is either still here:
Expand|Select|Wrap|Line Numbers
  1. Dim stDocName As String
  2.     Dim stLinkCriteria As String
  3.  
  4.    stLinkCriteria = "[txtkey]= me.txtkey"
  5.     stDocName = "Update"
  6.     DoCmd.RunCommand acCmdSaveRecord
  7.     DoCmd.openForm stDocName, , , stLinkCriteria
  8.  
or perhaps on the second form here:
Expand|Select|Wrap|Line Numbers
  1. With CurrentDb.OpenRecordset("tbl modifications") '===>i deleted dbopentable - did nothing
  2.  
  3.         .Edit
  4.             !key = DMax("[key]", "[tbl Modifications]")
  5.           !UpdateDate = Date
  6.           !Mod = Me.txtMOD
  7.           !MRD = Me.txtMRD
  8.           !SLD = Me.txtSLD
  9.           !SCD = Me.txtSCD
  10.           !OSD = Me.txtOSD
  11.           !ObligationDocument = Me.objObligationDocument
  12.  
  13.         .Update
  14.         .Bookmark = .LastModified
  15.       End With
edit:i changed !key to = Me.txtkey, it then proceeded to update the same record, which oddly was no longer the first record but the second to last(the first of two 201's), gave it a null value, and moved it back to the top. The Implications of this are beyond my current comprehension (though they perhaps support hypothesis that the problem lies in the second form?)
Jul 6 '07 #13
FishVal
2,653 Expert 2GB
Both tables are indeed bound to [tbl Modifications]. There has been some who question my logic (i don't believe its all that ab-normal hehheh) but for user simplicity's sake im rather stubborn about having two forms. I do have a functioning tabbed form which combines the two, so I could get to work on some other functions in the database, but I hate the d@mn thing.
Really!?

Form RecordSource property is set to [tbl Modifications] and form fields ControlSource properties are set to [tbl Modifications] corresponding fields??!! Let me know whether is it really so.

If so why you update [tbl Modifications] programmatically. It will do nothing in "Update" form and cause record duplication in "Input" form, which in its turn will cause PK violation error on [tbl Modifications].key writing.
Jul 6 '07 #14
*very embaressed
Really!?

Form RecordSource property is set to [tbl Modifications] and form fields ControlSource properties are set to [tbl Modifications] corresponding fields??!! Let me know whether is it really so.

If so why you update [tbl Modifications] programmatically. It will do nothing in "Update" form and cause record duplication in "Input" form, which in its turn will cause PK violation error on [tbl Modifications].key writing.
I don't(edit:do) think that the control source properties are set to fields in [tbl Modifications] (actually "txtkey" might be if what im doing in VB is setting control sources which as i type this begins to seem more likely)
Expand|Select|Wrap|Line Numbers
  1.  'in form1
  2. !key = DMax("[key]", "[tbl Modifications]") + 1
Expand|Select|Wrap|Line Numbers
  1. 'in form2
  2. !key = DMax("[key]", "[tbl Modifications]")
So in response to your 1st question: maybe?(edit:in response to your only question: yes)

Form1(imput) successfully adds a new record but as you said (well the inverse), Form2(update) duplicates the PK value. How can I get form2 to edit the record from Form1 without referencing the PK? Barring the sloppy thinking you've just pointed out I had been thinking my problem was in Form2 here:
Expand|Select|Wrap|Line Numbers
  1.  With CurrentDb.OpenRecordset("tbl Modifications", dbOpenTable)
edit:one last bit, in access form1(+2)>txtkey>Properties>control source = unbound, in case thats what you're asking about.
Jul 6 '07 #15
FishVal
2,653 Expert 2GB
*very embaressed


I don't(edit:do) think that the control source properties are set to fields in [tbl Modifications] (actually "txtkey" might be if what im doing in VB is setting control sources which as i type this begins to seem more likely)
Expand|Select|Wrap|Line Numbers
  1.  'in form1
  2. !key = DMax("[key]", "[tbl Modifications]") + 1
Expand|Select|Wrap|Line Numbers
  1. 'in form2
  2. !key = DMax("[key]", "[tbl Modifications]")
So in response to your 1st question: maybe?(edit:in response to your only question: yes)

Form1(imput) successfully adds a new record but as you said (well the inverse), Form2(update) duplicates the PK value. How can I get form2 to edit the record from Form1 without referencing the PK? Barring the sloppy thinking you've just pointed out I had been thinking my problem was in Form2 here:
Expand|Select|Wrap|Line Numbers
  1.  With CurrentDb.OpenRecordset("tbl Modifications", dbOpenTable)
I've meant form and form fields properties set when form was created or modified in Design view.
Open form (each form) in Design view and check whether form RecordSource property is set to [tbl Modifications] and form fields ControlSource properties are set to corresponding [tbl Modifications] fields.
If so record duplication actually occurs in "Input" form. When you start editing new record form automation creates new record, then your code do the same
Expand|Select|Wrap|Line Numbers
  1. With CurrentDB.OpenRecordset.....
  2.      .AddNew
  3.      .........
  4.      .Update
  5. End With
  6.  
P.S. I have to go now, will be back in 4-5 hours.
Jul 6 '07 #16
I've meant form and form fields properties set when form was created or modified in Design view.
Open form (each form) in Design view and check whether form RecordSource property is set to [tbl Modifications] and form fields ControlSource properties are set to corresponding [tbl Modifications] fields.
ok those are definately unbound. im pretty sure that the problem is that my editrecordButton on Form2 is copied pretty directly from the original addrecordButton on Form1 - i just changed .addnew to .edit
Expand|Select|Wrap|Line Numbers
  1. Private Private Sub comRecord_Click()
  2. Dim temp       As Variant
  3. On Error GoTo Err_comRecord_Click
  4.  
  5.     temp = SysCmd(acSysCmdSetStatus, "Filling table...")
  6.  
  7. With CurrentDb.OpenRecordset("tbl Modifications", dbOpenTable)
  8.         .Edit
  9.           !key = DMax("[key]", "[tbl Modifications]")
  10.           !UpdateDate = Date
  11.           !Mod = Me.txtMOD
  12.           !MRD = Me.txtMRD
  13.           !SLD = Me.txtSLD
  14.           !SCD = Me.txtSCD
  15.           !OSD = Me.txtOSD
  16.           !ObligationDocument = Me.objObligationDocument
  17.  
  18.         .Update
  19.         .Bookmark = .LastModified
  20.       End With
  21.  
  22. temp = SysCmd(acSysCmdClearStatus)
  23.  
  24. Exit_comRecord_Click:
  25.     Exit Sub
  26.  
  27. Err_comRecord_Click:
  28.     MsgBox Err.Description
  29.     Resume Exit_comRecord_Click
  30.  
  31. End Sub
Im going to look into this recordset business...
Jul 6 '07 #17
FishVal
2,653 Expert 2GB
ok those are definately unbound. im pretty sure that the problem is that my editrecordButton on Form2 is copied pretty directly from the original addrecordButton on Form1 - i just changed .addnew to .edit
Expand|Select|Wrap|Line Numbers
  1. Private Private Sub comRecord_Click()
  2. Dim temp As Variant
  3. On Error GoTo Err_comRecord_Click
  4.  
  5. temp = SysCmd(acSysCmdSetStatus, "Filling table...")
  6.  
  7. With CurrentDb.OpenRecordset("tbl Modifications", dbOpenTable)
  8. .Edit
  9. !key = DMax("[key]", "[tbl Modifications]")
  10. !UpdateDate = Date
  11. !Mod = Me.txtMOD
  12. !MRD = Me.txtMRD
  13. !SLD = Me.txtSLD
  14. !SCD = Me.txtSCD
  15. !OSD = Me.txtOSD
  16. !ObligationDocument = Me.objObligationDocument
  17.  
  18. .Update
  19. .Bookmark = .LastModified
  20. End With
  21.  
  22. temp = SysCmd(acSysCmdClearStatus)
  23.  
  24. Exit_comRecord_Click:
  25. Exit Sub
  26.  
  27. Err_comRecord_Click:
  28. MsgBox Err.Description
  29. Resume Exit_comRecord_Click
  30.  
  31. End Sub
Im going to look into this recordset business...
Code for record updating and, I'm pretty sure, there is also code for fields populating. Usually its better to let Access do it via bound form automation.
Why not to bind Form2 (maybe Form1 too, but Form2 definitely should be bound) to [tbl Modifications] and let Access do this behind the scenes?

BTW DoCmd.OpenForm with WhereCondition argument is indeed useless on unbound form.
Jul 7 '07 #18
Code for record updating and, I'm pretty sure, there is also code for fields populating. Usually its better to let Access do it via bound form automation.
Why not to bind Form2 (maybe Form1 too, but Form2 definitely should be bound) to [tbl Modifications] and let Access do this behind the scenes?

BTW DoCmd.OpenForm with WhereCondition argument is indeed useless on unbound form.
I just found a seldom used 'ammendment number' that will soon become manditory now that i can identify the records without the autonumber/dmax (procurement request + amendment number => PR + Mod # =yay!). I'm hoping with that it will be easier to reopen a record in a new form now that i wont be referencing calculated fields.... now if i could only find those postings on linking with multiple criteria....I'll be back just as soon as im in deep water again.

ps: SQL czars, gurus, etc beware - if things go well you're next
Jul 9 '07 #19
Ok so form two was indeed unbound, a problem which has been addressed.

this didnt work:
Expand|Select|Wrap|Line Numbers
  1. Dim stDocName As String
  2.     Dim stLinkCriteria As String
  3.  
  4.     stDocName = "Update"
  5.  
  6.     stLinkCriteria = "[txtkey]=" & Me!txtkey
  7.     DoCmd.openForm stDocName, , , stLinkCriteria
which leads to "syntax error (missing operator) in query expression '[txtkey]='

so i tried this approach:
Expand|Select|Wrap|Line Numbers
  1. DoCmd.openForm "Update"
  2.  
  3. Forms!Update!txtkey.SetFocus
  4.  
  5. DoCmd.FindRecord Forms![Input Form]!txtkey
which gives me "An expression you entered is the wrong data type for one of the arguements" (goes to error on last line)

any ideas?
Jul 10 '07 #20
FishVal
2,653 Expert 2GB
Ok so form two was indeed unbound, a problem which has been addressed.

this didnt work:
Expand|Select|Wrap|Line Numbers
  1. Dim stDocName As String
  2. Dim stLinkCriteria As String
  3.  
  4. stDocName = "Update"
  5.  
  6. stLinkCriteria = "[txtkey]=" & Me!txtkey
  7. DoCmd.openForm stDocName, , , stLinkCriteria
which leads to "syntax error (missing operator) in query expression '[txtkey]='

so i tried this approach:
Expand|Select|Wrap|Line Numbers
  1. DoCmd.openForm "Update"
  2.  
  3. Forms!Update!txtkey.SetFocus
  4.  
  5. DoCmd.FindRecord Forms![Input Form]!txtkey
which gives me "An expression you entered is the wrong data type for one of the arguements" (goes to error on last line)

any ideas?
Change the first code to this. WhereCondition argument in DoCmd.OpenForm has to have name of table field to the left of '=' not name of form control.

Expand|Select|Wrap|Line Numbers
  1. Dim stDocName As String
  2. Dim stLinkCriteria As String
  3.  
  4. stDocName = "Update"
  5.  
  6. stLinkCriteria = "key=" & Me!txtkey
  7. DoCmd.openForm stDocName, , , stLinkCriteria
Jul 10 '07 #21
this:
Expand|Select|Wrap|Line Numbers
  1.  Dim stDocName As String
  2. Dim stLinkCriteria As String
  3.  
  4. stDocName = "Update"
  5.  
  6. stLinkCriteria = "![keyID]=" & Me!txtkey
  7. DoCmd.openForm stDocName, , , stLinkCriteria
gives me a 'syntax error'

this:
Expand|Select|Wrap|Line Numbers
  1. DoCmd.openForm "Update", acNormal, , "!keyID='" & Me![txtkey] & "'", acFormEdit, acWindowNormal
prompts me for a parameter value for keyID

this (stolen from another of your posts):
Expand|Select|Wrap|Line Numbers
  1.  Dim stDocName As String
  2.     Dim stLinkCriteria As String
  3.  
  4.     stDocName = "Update"
  5.     stLinkCriteria = "[keyID]=" & "'" & Me![txtkey] & "'"
  6.  
  7.     With DoCmd
  8.         .RunCommand acCmdSaveRecord
  9.         .openForm stDocName, , , stLinkCriteria
  10.     End With
  11.  
  12.     Forms![Update]![txtkey].DefaultValue = Me![txtkey]
says command or action saverecord is unavailable.

when put in this:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Command85_Click()
  2.  
  3. On Error GoTo Err_Command85_Click
  4.  
  5.     With CurrentDb.OpenRecordset("tbl Modifications", dbOpenTable)
  6.         .AddNew
  7.           !Program = Me.txtProgram                         '\
  8.           !Name = Me.cboName                                 '|
  9.           !ObjectClass = Me.cboObjectClass
  10.           !ParentProgram = Me.txtParentProgram
  11.           !Fund = Me.txtfund
  12.           !ReportingEntity = Me.txtReportingEntity
  13.           !PurchaseOrder = Me.txtPurchaseOrder
  14.           !Comments = Me.txtComments
  15.           !AppropriationYear = Me.cboAppropriationYear
  16.           !Site = Me.txtsite
  17.           !DOR = Me.txtDOR
  18.           !FiscalYear = Me.cboFiscalYear                            '|
  19.           !Description = Me.txtdescription                           '|
  20.           !Budget = Me.txtCharge                             '|
  21.           !UpdateDate = Date
  22.           !SSD = Me.txtSSD
  23.           !CertifiedDocument = Me.objRequest
  24.           !BCD = Me.txtBCD
  25.           !FCD = Me.txtFCD
  26.           !Vendor = Me.txtVendor
  27.           !Amendment = Me.txtAmendment
  28.  
  29.         .Update
  30.         .Bookmark = .LastModified
  31.  
  32.    End With  
  33.  
  34. Exit_Command85_Click:
  35.     Exit Sub
  36.  
  37. Err_Command85_Click:
  38.     MsgBox Err.Description
  39.     Resume Exit_Command85_Click
  40.  
  41. End Sub
Jul 10 '07 #22
FishVal
2,653 Expert 2GB
this:
Expand|Select|Wrap|Line Numbers
  1.  Dim stDocName As String
  2. Dim stLinkCriteria As String
  3.  
  4. stDocName = "Update"
  5.  
  6. stLinkCriteria = "![keyID]=" & Me!txtkey
  7. DoCmd.openForm stDocName, , , stLinkCriteria
gives me a 'syntax error'

this:
Expand|Select|Wrap|Line Numbers
  1. DoCmd.openForm "Update", acNormal, , "!keyID='" & Me![txtkey] & "'", acFormEdit, acWindowNormal
prompts me for a parameter value for keyID

this (stolen from another of your posts):
Expand|Select|Wrap|Line Numbers
  1.  Dim stDocName As String
  2. Dim stLinkCriteria As String
  3.  
  4. stDocName = "Update"
  5. stLinkCriteria = "[keyID]=" & "'" & Me![txtkey] & "'"
  6.  
  7. With DoCmd
  8. .RunCommand acCmdSaveRecord
  9. .openForm stDocName, , , stLinkCriteria
  10. End With
  11.  
  12. Forms![Update]![txtkey].DefaultValue = Me![txtkey]
says command or action saverecord is unavailable.

when put in this:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Command85_Click()
  2.  
  3. On Error GoTo Err_Command85_Click
  4.  
  5. With CurrentDb.OpenRecordset("tbl Modifications", dbOpenTable)
  6. .AddNew
  7. !Program = Me.txtProgram '\
  8. !Name = Me.cboName '|
  9. !ObjectClass = Me.cboObjectClass
  10. !ParentProgram = Me.txtParentProgram
  11. !Fund = Me.txtfund
  12. !ReportingEntity = Me.txtReportingEntity
  13. !PurchaseOrder = Me.txtPurchaseOrder
  14. !Comments = Me.txtComments
  15. !AppropriationYear = Me.cboAppropriationYear
  16. !Site = Me.txtsite
  17. !DOR = Me.txtDOR
  18. !FiscalYear = Me.cboFiscalYear '|
  19. !Description = Me.txtdescription '|
  20. !Budget = Me.txtCharge '|
  21. !UpdateDate = Date
  22. !SSD = Me.txtSSD
  23. !CertifiedDocument = Me.objRequest
  24. !BCD = Me.txtBCD
  25. !FCD = Me.txtFCD
  26. !Vendor = Me.txtVendor
  27. !Amendment = Me.txtAmendment
  28.  
  29. .Update
  30. .Bookmark = .LastModified
  31.  
  32. End With 
  33.  
  34. Exit_Command85_Click:
  35. Exit Sub
  36.  
  37. Err_Command85_Click:
  38. MsgBox Err.Description
  39. Resume Exit_Command85_Click
  40.  
  41. End Sub
Post [tbl Modifications] metadata. Example given below.
Here is an example of how to post table MetaData :
Table Name=tblStudent
Expand|Select|Wrap|Line Numbers
  1. Field; Type; IndexInfo
  2. StudentID; AutoNumber; PK
  3. Family; String; FK
  4. Name; String
  5. University; String; FK
  6. Mark; Numeric
  7. LastAttendance; Date/Time
Jul 10 '07 #23
I figured much of my problems out, partially a bound form thing, partially through a different approach.

Form1 opens an existing blank record, which it edits, "saves", and opens in a new form. It then closes and generates a new blank for when it opens next.

heres the problem: Values inputed on Form1 fail to save, automatically or even when instructed. my code follows...



from the pulldown menu:

Expand|Select|Wrap|Line Numbers
  1. Sub openForm()
  2.   DoCmd.openForm "Input Form", acNormal, , "[EntryStatus] = 0", acFormEdit, acWindowNormal
  3. End Subon 
click event:
Expand|Select|Wrap|Line Numbers
  1.   With DoCmd
  2.  
  3.         .RunCommand acCmdSaveRecord
  4.  
  5.         .RunSQL "UPDATE [tbl Modifications] SET [EntryStatus]=(1) WHERE [keyID]= [txtkey]"
  6.  
  7.         .openForm "Update", acNormal, , "[keyID]=" & Me!txtkey, acFormEdit, acWindowNormal
  8.  
  9.         .Close acForm, Me.Name
  10.  
  11.         End With
onclose:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Close()
  2.  
  3.  
  4. With CurrentDb.OpenRecordset("tbl Modifications", dbOpenTable)
  5.         .AddNew
  6.           !EntryStatus = 0
  7.           .Update
  8. End With
  9.  
  10. End Sub
Jul 12 '07 #24
got this one. my controls were still unbound. oops.
Jul 12 '07 #25

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Sue Adams | last post by:
I actually have two issues/questions: I have an autonumber field in an access db table that I grab and later use to update a record in another table withing the same db. The code I use to get...
9
by: Dom Boyce | last post by:
Hi First up, I am using MS Access 2002. I have a database which records analyst rating changes for a list of companies on a daily basis. Unfortunately, the database has been set up (by my...
4
by: Jonathan Upright | last post by:
Greetings to anyone who can help: I'm using WebMatrix to make ASP.NET pages, and I chose the "Editable DataGrid" at the project selector screen. As you may know, it defaults to the Microsoft...
1
by: mursyidatun ismail | last post by:
Dear all, database use: Ms Access. platform: .Net i'm trying to update a record/records in a table called t_doctors by clicking da edit link provided in the database. when i ran through da...
1
by: Mark Reed | last post by:
Hi All, I'm having a problem with the following code. I've read quite a lot of old posts regarding the issue but none seem to affer a solution. The scenario is. I have a bound form which...
5
by: Stephen Plotnick | last post by:
I'm very new to VB.NET 2003 Here is what I have accomplished: MainSelectForm - Selects an item In a public class I pass a DataViewRow to ItemInformation1 Form ItemInformation2 Form
9
by: mtgrizzly52 | last post by:
Hi all, I've looked for an answer for this in lots of books, online in several discussion groups and have not found the answer which I feel may be very simple. What I want to do is have a...
0
by: Access Programming only with macros, no code | last post by:
ERROR MESSAGE: Could not update; currently locked by another session on this machine. BACKGROUND I have the following objects: Table1 - HO (which has about 51,000+ records) Table2 -...
1
by: teenagelcruise | last post by:
hi, i have a problem with my code which is i cannot update and addnew data into the database but i can delete the data.plz give me an idea.this is my code that i wrote. <html> <head> <meta...
2
by: sirdavethebrave | last post by:
Hi guys - I have written a form, and a stored procedure to update the said form. It really is as simple as that. A user can go into the form, update some fields and hit the update button to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.