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. -
DoCmd.OpenForm "FormName", acNormal
-
Any Help Will Be Appreciated,
Bender
PS - If I open the form directly, I do not get the error.
9 1479
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)>
Basically the code for the Submit button which opens the form is:
X and Y are String data types -
if ComboBox1 = X and cbo2 = Y then
-
docmd.openform "formname", acNormal
-
end if
-
Then here is the code that is produces the error. Note, it works as it should when opening the form directly, without the comboboxes. -
Dim date_cleaned, Cell
-
Dim cleanings
-
Dim PDate As Date
-
-
PDate = DateValue(Format(Now, "mm/dd/yyyy"))
-
Cell = txt_cell
-
-
-
Call last_cleaned 'Runs An Append Query. Appending Last Cleaned Date and count of cleanings to table "tbl_Last_Date_Cleaned_91-1"
-
-
cleanings = DLookup("[Number of Cleanings]", "tbl_Last_Date_Cleaned_91-1")
-
date_cleaned = DLookup("[LastOfDate]", "tbl_Last_Date_Cleaned_91-1")
-
-
If txt_frequency = "Twice a Shift" And cleanings <= 1 And date_cleaned <= PDate Then
-
DoCmd.OpenQuery ("qry_Delete_Last_Date_Cleaned_91-1")
-
Exit Sub
-
Else
-
DoCmd.GoToRecord , , acNext 'This Is Where The Error Occurs
-
DoCmd.OpenQuery ("qry_Delete_Last_Date_Cleaned_91-1")
-
End If
-
Bender
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)?
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 -
Private Sub Form_Open(Cancel As Integer)
-
Dim current_day
-
-
-
DoCmd.RunMacro ("Minimize") 'Minimizes the Access window allowing just the form to be visible
-
current_day = Format(Weekday(Now, vbSunday), "dddd")
-
-
-
If current_day = "Sunday" Then
-
ck_sunday.Enabled = True
-
ck_monday.Enabled = False
-
ck_tuesday.Enabled = False
-
ck_wednesday.Enabled = False
-
ck_thursday.Enabled = False
-
ck_friday.Enabled = False
-
ck_sunday = 0
-
-
-
ElseIf current_day = "Monday" Then
-
ck_sunday.Enabled = False
-
ck_monday.Enabled = True
-
ck_tuesday.Enabled = False
-
ck_wednesday.Enabled = False
-
ck_thursday.Enabled = False
-
ck_friday.Enabled = False
-
ck_monday = 0
-
-
-
ElseIf current_day = "Tuesday" Then
-
ck_sunday.Enabled = False
-
ck_monday.Enabled = False
-
ck_tuesday.Enabled = True
-
ck_wednesday.Enabled = False
-
ck_thursday.Enabled = False
-
ck_friday.Enabled = False
-
ck_tuesday = 0
-
-
ElseIf current_day = "Wednesday" Then
-
ck_sunday.Enabled = False
-
ck_monday.Enabled = False
-
ck_tuesday.Enabled = False
-
ck_wednesday.Enabled = True
-
ck_thursday.Enabled = False
-
ck_friday.Enabled = False
-
ck_wednesday = 0
-
-
ElseIf current_day = "Thursday" Then
-
ck_sunday.Enabled = False
-
ck_monday.Enabled = False
-
ck_tuesday.Enabled = False
-
ck_wednesday.Enabled = False
-
ck_thursday.Enabled = True
-
ck_friday.Enabled = False
-
ck_thursday = 0
-
-
ElseIf current_day = "Friday" Then
-
ck_sunday.Enabled = False
-
ck_monday.Enabled = False
-
ck_tuesday.Enabled = False
-
ck_wednesday.Enabled = False
-
ck_thursday.Enabled = False
-
ck_friday.Enabled = True
-
ck_friday = 0
-
-
ElseIf current_day = "Saturday" Then
-
ck_sunday.Enabled = False
-
ck_monday.Enabled = False
-
ck_tuesday.Enabled = False
-
ck_wednesday.Enabled = False
-
ck_friday.Enabled = False
-
ck_saturday.Enabled = True
-
ck_saturday = 0
-
End If
-
-
End Sub
-
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. - Private Sub Form_Open(Cancel As Integer)
-
Dim Current_Day As String
-
Dim ctlMe As Control
-
-
DoCmd.RunMacro ("Minimize") 'Minimizes the Access window allowing just the form to be visible
-
Current_Day = Format(Date(), "dddd")
-
-
ck_Sunday.Enabled = False
-
ck_Monday.Enabled = False
-
ck_Tuesday.Enabled = False
-
ck_Wednesday.Enabled = False
-
ck_Thursday.Enabled = False
-
ck_Friday.Enabled = False
-
ck_Saturday.Enabled = False
-
-
For Each ctlMe In Me.Controls
-
If Mid(ctlMe.Name, 4) = Current_Day Then
-
ctlMe.Enabled = True
-
ctlMe = 0
-
End If
-
Next ctlMe
-
-
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.
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. -
Private Sub Aggitator()
-
Dim msg, style, title, response
-
Dim Unit, Cell
-
-
Unit = txt_unit
-
Cell = txt_cell
-
-
If txt_frequency = "" Or IsNull(txt_frequency) = True Or IsNull(Cell) = True Then
-
msg = "There Is Currently No Cell That Needs Maintenance At This Time."
-
style = vbOKOnly + vbInformation + defaultbutton2
-
title = "Plus Bank Maintenance"
-
response = MsgBox(msg, style, title)
-
ck_sunday.Enabled = False
-
ck_monday.Enabled = False
-
ck_tuesday.Enabled = False
-
ck_wednesday.Enabled = False
-
ck_thursday.Enabled = False
-
ck_friday.Enabled = False
-
Else
-
-
If txt_frequency = "Twice a Shift" Then
-
Call frequency_check_shift 'Each of these is basically the same as (Post #3)
-
End If
-
-
If txt_frequency = "Daily" Then
-
Call frequency_check_daily
-
End If
-
-
If txt_frequency = "Weekly" Then
-
Call frequency_check_weekly
-
End If
-
-
If txt_frequency = "Monthly" Then
-
Call frequency_check_monthly
-
End If
-
-
-
End If
-
-
End Sub
-
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.
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
NeoPa 32,556
Expert Mod 16PB
... - 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 :)
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
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...
|
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...
|
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:
-----------...
|
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)....
|
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...
|
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...
|
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...
|
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...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
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
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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: 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...
|
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...
| |