473,395 Members | 1,905 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,395 software developers and data experts.

Problem Moving To Next Record

MindBender77
234 100+
Hello All,
I believe I have a simple problem but, can't seem to find a easy solution. First, I developed a form (popup) with 2 combo boxes and a submit button.

When I make a choice from both cbo and click submit, a form corresponding to the entries are displayed. However, when the form tries to open, I get an error stating "Can Not Go To Specified Record in Design View."

I'm using the this code to open the form.
Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenForm "FormName", acNormal
  2.  
Any Help Will Be Appreciated,
Bender

PS - If I open the form directly, I do not get the error.
Apr 11 '08 #1
9 1479
missinglinq
3,532 Expert 2GB
When I make a choice from both cbo and click submit, a form corresponding to the entries are displayed.
Are you, in fact, asking Access to go to a particular record when the form opens, and if so, how?

There's obviously nothing wrong with the code you've posted, but neither does it demonstrate how the values selected from your comboboxes are being assigned to this process, and we need to see that code.

Linq ;0)>
Apr 11 '08 #2
MindBender77
234 100+
Basically the code for the Submit button which opens the form is:
X and Y are String data types
Expand|Select|Wrap|Line Numbers
  1. if ComboBox1 = X and cbo2 = Y then
  2. docmd.openform "formname", acNormal
  3. end if
  4.  
Then here is the code that is produces the error. Note, it works as it should when opening the form directly, without the comboboxes.
Expand|Select|Wrap|Line Numbers
  1. Dim date_cleaned, Cell
  2. Dim cleanings
  3. Dim PDate As Date
  4.  
  5.     PDate = DateValue(Format(Now, "mm/dd/yyyy"))
  6.     Cell = txt_cell
  7.  
  8.  
  9.     Call last_cleaned 'Runs An Append Query.  Appending Last Cleaned Date and count of cleanings to table "tbl_Last_Date_Cleaned_91-1"
  10.  
  11.     cleanings = DLookup("[Number of Cleanings]", "tbl_Last_Date_Cleaned_91-1")
  12.     date_cleaned = DLookup("[LastOfDate]", "tbl_Last_Date_Cleaned_91-1")
  13.  
  14.     If txt_frequency = "Twice a Shift" And cleanings <= 1 And date_cleaned <= PDate Then
  15.         DoCmd.OpenQuery ("qry_Delete_Last_Date_Cleaned_91-1")
  16.         Exit Sub
  17.     Else
  18.         DoCmd.GoToRecord , , acNext 'This Is Where The Error Occurs
  19.         DoCmd.OpenQuery ("qry_Delete_Last_Date_Cleaned_91-1")
  20.     End If
  21.  
Bender
Apr 11 '08 #3
NeoPa
32,556 Expert Mod 16PB
Frustratingly, probably the most important piece of information is what you left out :D

Where is the second batch of code to be found and what is the procedure called (I suspect it may be the Form_Open() procedure in the form's own module)?
Apr 11 '08 #4
MindBender77
234 100+
I didn't think the OnOpen was causing the issue but, then again, I'm the one stumped on this so any help would be tremendous:

Bender

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Open(Cancel As Integer)
  2. Dim current_day
  3.  
  4.  
  5. DoCmd.RunMacro ("Minimize") 'Minimizes the Access window allowing just the form to be visible
  6. current_day = Format(Weekday(Now, vbSunday), "dddd")
  7.  
  8.  
  9. If current_day = "Sunday" Then
  10. ck_sunday.Enabled = True
  11. ck_monday.Enabled = False
  12. ck_tuesday.Enabled = False
  13. ck_wednesday.Enabled = False
  14. ck_thursday.Enabled = False
  15. ck_friday.Enabled = False
  16. ck_sunday = 0
  17.  
  18.  
  19. ElseIf current_day = "Monday" Then
  20. ck_sunday.Enabled = False
  21. ck_monday.Enabled = True
  22. ck_tuesday.Enabled = False
  23. ck_wednesday.Enabled = False
  24. ck_thursday.Enabled = False
  25. ck_friday.Enabled = False
  26. ck_monday = 0
  27.  
  28.  
  29. ElseIf current_day = "Tuesday" Then
  30. ck_sunday.Enabled = False
  31. ck_monday.Enabled = False
  32. ck_tuesday.Enabled = True
  33. ck_wednesday.Enabled = False
  34. ck_thursday.Enabled = False
  35. ck_friday.Enabled = False
  36. ck_tuesday = 0
  37.  
  38. ElseIf current_day = "Wednesday" Then
  39. ck_sunday.Enabled = False
  40. ck_monday.Enabled = False
  41. ck_tuesday.Enabled = False
  42. ck_wednesday.Enabled = True
  43. ck_thursday.Enabled = False
  44. ck_friday.Enabled = False
  45. ck_wednesday = 0
  46.  
  47. ElseIf current_day = "Thursday" Then
  48. ck_sunday.Enabled = False
  49. ck_monday.Enabled = False
  50. ck_tuesday.Enabled = False
  51. ck_wednesday.Enabled = False
  52. ck_thursday.Enabled = True
  53. ck_friday.Enabled = False
  54. ck_thursday = 0
  55.  
  56. ElseIf current_day = "Friday" Then
  57. ck_sunday.Enabled = False
  58. ck_monday.Enabled = False
  59. ck_tuesday.Enabled = False
  60. ck_wednesday.Enabled = False
  61. ck_thursday.Enabled = False
  62. ck_friday.Enabled = True
  63. ck_friday = 0
  64.  
  65. ElseIf current_day = "Saturday" Then
  66. ck_sunday.Enabled = False
  67. ck_monday.Enabled = False
  68. ck_tuesday.Enabled = False
  69. ck_wednesday.Enabled = False
  70. ck_friday.Enabled = False
  71. ck_saturday.Enabled = True
  72. ck_saturday = 0
  73. End If
  74.  
  75. End Sub
  76.  
Apr 14 '08 #5
NeoPa
32,556 Expert Mod 16PB
Bender, I suspect, in effect, it's not (though I have provided an alternative that's a little shorter).

What I was asking for (sorry I didn't make this clearer) was the information that showed how the second block of code in your post (#3) fitted into the situation (how is it executed).

What you provided was fine, but I couldn't see what I needed in it so I asked for some extra info. Clearly you were careful not to overload the post with useless info which I can only applaud, but sometimes useful bits are missed out too. It's a call you have to make, and I far prefer posters who make that call and maybe get it a little wrong to those who don't even get the concept.
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Open(Cancel As Integer)
  2.   Dim Current_Day As String
  3.   Dim ctlMe As Control
  4.  
  5.   DoCmd.RunMacro ("Minimize") 'Minimizes the Access window allowing just the form to be visible
  6.   Current_Day = Format(Date(), "dddd")
  7.  
  8.   ck_Sunday.Enabled = False
  9.   ck_Monday.Enabled = False
  10.   ck_Tuesday.Enabled = False
  11.   ck_Wednesday.Enabled = False
  12.   ck_Thursday.Enabled = False
  13.   ck_Friday.Enabled = False
  14.   ck_Saturday.Enabled = False
  15.  
  16.   For Each ctlMe In Me.Controls
  17.     If Mid(ctlMe.Name, 4) = Current_Day Then
  18.       ctlMe.Enabled = True
  19.       ctlMe = 0
  20.     End If
  21.   Next ctlMe
  22.  
  23. End Sub
In your code ck_Saturday was omitted from most groups (and ck_Thursday was omitted for the Saturday group). I assumed this was an oversight and coded accordingly.
Apr 14 '08 #6
MindBender77
234 100+
I am uncertain on the usage of "For Each" and I seem to stay away from it. As you illustrated, I definitely have to build up my confidence in its functions.

As for the code I left out: At the end of the OnOpen event, there is a call to a sub. Here is its code. Note: The call frequency_check_daily is from Post #3.
Expand|Select|Wrap|Line Numbers
  1. Private Sub Aggitator()
  2. Dim msg, style, title, response
  3. Dim Unit, Cell
  4.  
  5. Unit = txt_unit
  6. Cell = txt_cell
  7.  
  8. If txt_frequency = "" Or IsNull(txt_frequency) = True Or IsNull(Cell) = True Then
  9. msg = "There Is Currently No Cell That Needs Maintenance At This Time."
  10. style = vbOKOnly + vbInformation + defaultbutton2
  11. title = "Plus Bank Maintenance"
  12. response = MsgBox(msg, style, title)
  13. ck_sunday.Enabled = False
  14. ck_monday.Enabled = False
  15. ck_tuesday.Enabled = False
  16. ck_wednesday.Enabled = False
  17. ck_thursday.Enabled = False
  18. ck_friday.Enabled = False
  19. Else
  20.  
  21. If txt_frequency = "Twice a Shift" Then
  22. Call frequency_check_shift 'Each of these is basically the same as (Post #3)
  23. End If
  24.  
  25. If txt_frequency = "Daily" Then
  26. Call frequency_check_daily
  27. End If
  28.  
  29. If txt_frequency = "Weekly" Then
  30. Call frequency_check_weekly
  31. End If
  32.  
  33. If txt_frequency = "Monthly" Then
  34. Call frequency_check_monthly
  35. End If
  36.  
  37.  
  38. End If
  39.  
  40. End Sub
  41.  
Apr 14 '08 #7
NeoPa
32,556 Expert Mod 16PB
I'm sorry, but it's still unclear where the code (the stuff with the error in) is being run from.

This is particularly important as the line where the error occurs is unspecific code. It works on the current object (not on the form that's yet to be opened) so without knowing where we are at the time of execution I can see no way to determine what's going wrong.
Apr 15 '08 #8
MindBender77
234 100+
I'm sorry for being unclear,Neopa. I do appreciate all your help. I'm going to attempt to find the solution through alittle trial and error since I'm between projects. I don't want to fill this thread with useless code snippits and waste yours and others time when it could be used helping others. I'll post the solution when it is found.

Thanks Again,
Bender
Apr 15 '08 #9
NeoPa
32,556 Expert Mod 16PB
...
Expand|Select|Wrap|Line Numbers
  1. DoCmd.GoToRecord , , acNext 'This Is Where The Error Occurs
...
OK No worries.

If I can just share my thoughts so far, they may be of some help.

I'm guessing (can't be sure) that this line is intended to operate within a form (possibly the one that has yet to be called) but is actually operating elsewhere. This is a side-effect of the API provided to be very general purpose (DoCmd...). If possible (it isn't in all cases unfortunately) re-code this to refer to an object explicitly. This has a side-effect of being more obvious when read too (so is better coding practice generally).

Good luck with your attempts and let us know how you get on :)
Apr 15 '08 #10

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

Similar topics

0
by: RT | last post by:
Hello; I'm trying to create a updates pages that I can move either to the previous record or the next record within a recordset without having to return to the repeating list of records after...
0
by: James | last post by:
Hello group: I don't know if this is by design, or something I can change: I recently migrated one of our Access tables to SQL server. Now, when the form bound to the query for that table is...
4
by: William Wisnieski | last post by:
Hello Everyone, Access 2000 I have a form with multiple pages on it. There is one text field on the third page of the form that I need the user to complete before leaving the form or moving...
2
by: Doslil | last post by:
hi, I have a drop down list on the main form which has a query attached to it.Looks like the record is not moving to the next record,cos when I select the next record from the list it gives an...
5
by: Prakash | last post by:
I have a continuous form in which I don't want to allow more than 255 rows. There is a field called sub_tran_no which is of the type "BYTE" & hence the restriction. My Problem: -----------...
0
by: sandi | last post by:
Hi all, I have datagridview with one column how can i disable enter key action so the when i press enter key active record not moving to next record (but still stand in current record in grid)....
11
by: scsTiger | last post by:
I am using Access 2000 as the front end and MS SQL 2000 as the backend. I have a one record form that I set using something like: strSQL = "SELECT * FROM dbo_WBACCT WHERE...
3
prn
by: prn | last post by:
Hi folks, I've got something that's driving me crazy here. If you don't want to read a long explanation, this is not the post for you. My problematic Access app is a DB for keeping track of...
2
by: Arnold | last post by:
Hi Gurus, I am getting the error 3420 "object invalid or no longer set" at in the line -- rst.FindFirst "=" & NextPK --in the code below. I simply have a continuous main form that is, by...
5
by: adarshyam | last post by:
Hi friends, I have an interesting problem in vb.net. And I am struggling to get a solution for this..m trying for the past 3days.. It’s to calculate moving average for the inputs given by the...
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: 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:
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
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...
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...

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.