473,385 Members | 2,069 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,385 software developers and data experts.

"No current Record" after form requery

72 64KB
Hi,

after I requery a form, if I do



Expand|Select|Wrap|Line Numbers
  1.    Me.Requery
  2.    Dim rs As DAO.Recordset
  3.  
  4.  
  5.    Set rs = Forms!frmMain.Recordset
  6.           With rs                    
  7.               .Edit
  8.                     !fkLocationID = Me.lbxLocation
  9.                 .Update
  10.               End With
This throws an error at .Edit. Why?

if I do
Dim rs As DAO.Recordset

Expand|Select|Wrap|Line Numbers
  1. Set rs = Forms!frmMain.Recordset
  2.                  With rs
  3.                      .Bookmark = Forms!frmMain.Bookmark
  4.                     .Edit
  5.                         !fkLocationID = Me.lbxLocation
  6.                     .Update
  7.                  End With
It works fine but i was under the impression that after a form requery the first record is current and the recordset pointer too?
Nov 15 '17 #1

✓ answered by PhilOfWalton

I think your problem is you can edit a record within a recordset. In your first example Access hasn't the foggiest idea which record needs changing. The bookmark defines which record you are talking about.

Phil

9 4342
PhilOfWalton
1,430 Expert 1GB
I think your problem is you can edit a record within a recordset. In your first example Access hasn't the foggiest idea which record needs changing. The bookmark defines which record you are talking about.

Phil
Nov 15 '17 #2
Neruda
72 64KB
ok but the form shows me the first record in the form textboxes. Isn't that the current record?
I thought the recordset cursor moves together with the form and the recordsetclone is indipendent.
Nov 15 '17 #3
PhilOfWalton
1,430 Expert 1GB
Until you click on a record, it isn't the current record - just the one that is showing.

Phil
Nov 15 '17 #4
Neruda
72 64KB
should't it happen also when a form loads for the first time too? doesn't seem to happen when it is loaded. i also get the error when i close the form using the X button, but it seems random. Not sure what I am doing wrong
Nov 15 '17 #5
NeoPa
32,556 Expert Mod 16PB
PhilOfWalton:
Until you click on a record, it isn't the current record - just the one that is showing.
I'm sorry Phil but that's not correct. The Form_Current() event occurs after the form's opened when the first record is selected.
Nov 15 '17 #6
Neruda
72 64KB
So I am still not clear.
every time a form is opened or a form is required, the Form_Current()fires. In both cases the first record in the recordset is selected.
So why is Access complaining that there is not current record if I do (after a requery) but not when loading the form.
Expand|Select|Wrap|Line Numbers
  1.     Me.Requery
  2.     Dim rs As DAO.Recordset
  3.  
  4.     Set rs = Forms!frmMain.Recordset
  5.     With rs                    
  6.         .Edit
  7.         !fkLocationID = Me.lbxLocation
  8.         .Update
  9.     End With
Nov 18 '17 #7
NeoPa
32,556 Expert Mod 16PB
Neruda:
So why is Access complaining that there is not current record if I do (after a requery) but not when loading the form.
If you do what Neruda? Your post is unclear and the code posted is a mess. How can you expect intelligent responses when you take no care over what you post.

I also had to reset your selection of Best Answer. It is not appropriate to click that unless it answers your question. As that particular post is inaccurate, and you are continuing to request help, then it clearly didn't. It's not fair on anyone to have a Best Answer post reset due to your carelessness.
Nov 18 '17 #8
NeoPa
32,556 Expert Mod 16PB
It's possible to have a form where no record is current. However, this is not the case when there are any records available and the form is just opened. More I can't say as what you describe is so unclear. I don't even know where in that code - if even anywhere in that code - that you get a message saying no current record.
Nov 18 '17 #9
Neruda
72 64KB
That code looks brutal indeed. Apologies to anyone trying to help/reading this. I admit I wrote it in a hurry.

Phil answered the question, I was trying to understand why I need to bookmark the recordset after requerying a form if I want to edit the recordset. I assumed that, after a form requery, the record shown in the form is the current one.


This is the code in which the error occurred ( .Edit):



Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdTableAdd_Click()
  2.     'On Error GoTo ErrorHandler
  3.  
  4.     Dim rst As DAO.Recordset
  5.     Dim targetForm As Form
  6.  
  7. 'open form to add table in dialog mode
  8.     DoCmd.OpenForm "frmTableAdd", acNormal, , , , acDialog, Nz(Me!fkLocationID, 0)
  9.  
  10. 'check if frmTableAdd is loaded or the Cancel button was pressed
  11.     If CurrentProject.AllForms("frmTableAdd").IsLoaded = True Then
  12.         Set targetForm = Forms("frmTableAdd")
  13.  
  14. 'determine if the user wants to change or add a new table
  15.         If targetForm!tbTableManagement.Value = 0 Then   
  16.             DoCmd.OpenQuery "qry_frmMainAppend"
  17.             Me.Requery                   
  18.             comboLocation.Requery
  19.             comboLocation = comboLocation.ItemData(0)
  20.         Else                                              'change Table location
  21.             Set rst = Me.Recordset
  22.                 With rst
  23.         error ->    .Edit
  24.                         !fkLocationID = targetForm!lbxLocation
  25.                     .Update
  26.                 End With
  27.                 Me.cmdTableSelect.Caption = Me!LocationName
  28.                 comboLocation.Requery
  29.         End If
  30.  
  31.         DoCmd.Close acForm, "frmTableAdd"
  32.  
  33.     End If
  34.  
  35. ExitSub:
  36.     Set rst = Nothing
  37.     Exit Sub
  38. ErrorHandler:
  39.     MsgBox "Error No: " & Err.Number & vbNewLine _
  40.          & "Error Details: " & Err.Description & vbNewLine _
  41.          & "Error in Sub: frmTableAdd\cmdTableAdd_Click"
  42.     Resume ExitSub
  43.  
  44. End Sub
Nov 19 '17 #10

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

Similar topics

1
by: M Wells | last post by:
Hi All, I am developing an Access 2003 project application with the back end in SQL Server 2003. I have a master form that tracks projects, and several subforms on it that track various...
4
by: Jackson via AccessMonster.com | last post by:
Hi, I've got a form where multiple users will be 'booking' their trades. Several bound fields have on update/change requery code for the Form, this is to limit the rest of the fields based on...
8
by: Michael R | last post by:
Dear users and experts, An unbound combo box in my form is responsible for changing a city name for an update query that creates a temprorary table which the form uses as its record source. In...
11
by: mrowe | last post by:
I am using Access 2003. (I am also using ADO in the vast majority of my code. I recently read a post that indicated that ADO is not all that is was initially cracked up to be. In the back of my...
9
by: saddist | last post by:
Hello, I just can't get thru it. I have a form and a subform in it. Subform is tabular and it displays a query(Id,name,date). In main form I have text field "enterDateFrom" and "enterDateTo". I...
3
by: Gilberto | last post by:
Hello, I have a form with some buttons that take the user to reports, other forms, etc. On this form the user can see how many products are missing costing and pricing information, through some...
0
by: Jeff | last post by:
I don't remember this being that hard. Or maybe it's just early senility. On a simple bound continuous form I have a combo for filtering the form by customer. The form record source is a sql...
1
by: DAObermeyer | last post by:
Hey all, first time here. I have a database that is designed to be opened and viewed at other locations on the network. I use Form (A) to modify Data in Table (A), and Form (B) is used scrictly...
3
by: luvukrishna | last post by:
hello sir, i am into a project were i don't want my client to access the system until he types the user name and password correctly.........for this i need to stop him to access other application...
1
by: gstylianou | last post by:
Dear all, I would like to have your help.. I have a main a parent form which named 'frmCustomers" and a child form which called "frmCustomerInvoice". In child form a have some calculated...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...

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.