473,568 Members | 2,986 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Update Record in one Form and Open in another form?

thisisntwally
19 New Member
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 5056
FishVal
2,653 Recognized Expert Specialist
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
thisisntwally
19 New Member
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 Recognized Expert Specialist
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
thisisntwally
19 New Member
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 Recognized Expert Specialist
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
thisisntwally
19 New Member
???
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 Recognized Expert Specialist
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
thisisntwally
19 New Member
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 Recognized Expert Specialist
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

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

Similar topics

0
2771
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 it from the db table is: ''Retrieve the Registration Identification Number strRegisterID = Rs("Register_ID") Prior to testing my code and actually...
9
4337
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 predecessor, I hasten to add) so that each day it creates a copy of the record for each company, changes the date to today's date, and prompts the user...
4
2141
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 SQL database "pubs". I've followed the instructions in the comments and also changed everything pertaining to SQL over to OLEDB. (i.e. Changed...
1
2019
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 browsers and click update it gave me this error: Specified argument was out of the range of valid values. Parameter name:
1
8491
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 contains a couple of memo fields. I need to keep some sort of log as to when each update of the memo field occurs so I have locked bot the memo fields on...
5
2587
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
3328
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 switchboard with several active buttons on it for entering new data, updating data, reports etc. The new data and report stuff is easy, but the update...
0
3226
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 - Contact (which has 68,000+ records)
1
2454
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 http-equiv="Content-Type" content="text/html; charset=windows-1252"> <title>Order Record</title> <meta name="Microsoft Border" content="tlb, default">...
2
2621
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 update the information which is stored in a SQL database. In testing we noticed that the form was updating correctly but the update mechanism was also...
0
7917
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8118
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7665
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
5217
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3651
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3631
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2105
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1207
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
933
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.