By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,474 Members | 1,283 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,474 IT Pros & Developers. It's quick & easy.

Microsoft Access/VBA Forms

P: 2
I developed data entry forms in ms access. On the first form, user types ID number and all other forms captures the number. After user enter data in one form, they click on a button and the next form opens. The first past thru all forms works. The second pass, first two forms works fine, the third form gives error "DoCmd.OpenForm action cancelled" and does not capture ID number. Please help! This is the code for the button:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Command117_Click()
  2. On Error GoTo Err_Command117_Click
  3.  
  4. Dim stDocName As String
  5. Dim stLinkCriteria As String
  6. DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
  7.  
  8. stDocName = "FOURTH_PAGE"
  9.  
  10. stLinkCriteria = "[SUBJECT_ID]=" & "'" & Me![SUBJECT_ID] & "'"
  11. DoCmd.OpenForm stDocName, , , stLinkCriteria
  12. Forms![FOURTH_PAGE]![SUBJECT_ID].Value = Me![SUBJECT_ID].Value
  13. Forms![FOURTH_PAGE]![PEXAM].SetFocus
  14.  
  15. DoCmd.Close acForm, "THIRD_PAGE"
  16.  
  17.  
  18. Exit_Command117_Click:
  19. Exit Sub
  20.  
  21. Err_Command117_Click:
  22. MsgBox Err.Description
  23. Resume Exit_Command117_Click
  24.  
  25. End Sub
Apr 20 '10 #1
Share this Question
Share on Google+
4 Replies


TheSmileyCoder
Expert Mod 100+
P: 2,321
Hi and welcome to Bytes.

Please remember to use [code][/code] tags around your code, it makes it easier to read.

Between the lines
Expand|Select|Wrap|Line Numbers
  1. stLinkCriteria = "[SUBJECT_ID]=" & "'" & Me![SUBJECT_ID] & "'"
  2. DoCmd.OpenForm stDocName, , , stLinkCriteria
insert this line:
Expand|Select|Wrap|Line Numbers
  1. msgbox stLinkCriteria
To make sure the criteria looks as expected.
Furthermore if the forms have been set to Data Entry only, you do not actually need to open them with a criteria, as they will be "empty" when you open them
Apr 21 '10 #2

P: 2
Thank you for your reponse. This part of the project works now but yet another error has occurred. One of the tables was saving a blank record. I wrote a delete query and put it in the form_AfterUpdate event. This takes care of the blank record but when the user goes back to the previous record (maybe to correct or check) then comes back to the current record the run-time error 3329 occurs and it puts #DELETE in all of the forms controls. However if the user tab/enter thru the form or click on the next navigation button, they can continue entering and the entered data is in the table correctly. Any and all advice would be greatly appreciated.
Apr 28 '10 #3

TheSmileyCoder
Expert Mod 100+
P: 2,321
I honestly don't think you should write delete querys to handle empty record problems...You need to find out why a empty record is inserted in the first place.
Apr 28 '10 #4

NeoPa
Expert Mod 15k+
P: 31,768
I agree. That would be a more reliable way to resolve your issue. Otherwise you're likely to be falling over related problems for some while I expect.
Apr 28 '10 #5

Post your reply

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