473,699 Members | 2,384 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
24 5063
FishVal
2,653 Recognized Expert Specialist
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
thisisntwally
19 New Member
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 Recognized Expert Specialist
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
thisisntwally
19 New Member
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
thisisntwally
19 New Member
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
2776
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 updating the db, I''m trying to write it to the page to make sure their isn''t a loop or massive...
9
4351
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 for any changes of ratings on that day. The resulting data table grows by approx 600 records per...
4
2146
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 SqlDbType. to OleDbType.) I also changed the datafield names and variable names accordingly. The page...
1
2020
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
8500
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 the main form. To edit them, the user double clicks the ememo field which then opens an unbound...
5
2595
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
3332
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 button has me baffled. What I want to have happen is when the update button is clicked, a parameter...
0
3236
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
2458
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"> </head>
2
2634
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 updating the first record of the table in the sql database every time. No error messages are on...
0
8613
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9172
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8908
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
8880
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7745
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6532
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5869
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4374
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2344
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.