Form has no active record on opening (1 Viewer)

fluid

Registered User.
Local time
Today, 07:23
Joined
Nov 27, 2008
Messages
81
I have a split form that recently developed a problem.

when the form first opens, the active record is record #0 , I have no record 0 in my database. However, on the displayed form it shows the data for my first real record. and in the split (datasheet) portion of the split it shows all of my records.


When the form is first opened the on-current event doesn't seem to fire either (verified with a msgbox in the VBA event)
and
If I try to use my command buttons for "next", "previous", "last"and "first" records, I get an error "You can't go to the specified record"



I've added some debug.print code to verify that the record is actually zero as follows

Code:
 Private Sub Command108_Click()

Debug.Print "Name: " & Me.Application.CurrentObjectName
Debug.Print "ME Name: " & Me.Name
Debug.Print "Recordsource: " & Me.RecordSource
Debug.Print "Record #: " & Me.CurrentRecord
Debug.Print "Record Count: " & Me.Recordset.RecordCount


End Sub
the results are:


Name: frmAssets
ME Name: frmAssets
Recordsource: qryAssets
Record #: 0
Record Count: 1153
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 15:23
Joined
Sep 12, 2006
Messages
15,634
most likely your form query doesn't return any records. Maybe the query is not updateable, but I don't think you would get that form appearance with that problem.

Is your form set to data entry true? That would show a form waiting for an entry.
 

fluid

Registered User.
Local time
Today, 07:23
Joined
Nov 27, 2008
Messages
81
most likely your form query doesn't return any records. Maybe the query is not updateable, but I don't think you would get that form appearance with that problem.

Is your form set to data entry true? That would show a form waiting for an entry.


Here are my form settings.
Capture.JPG


Also, Once the form is opened, if I manually select a record from the splitform datasheet, the main form goes to that record, and everything works fine after that.
 

Minty

AWF VIP
Local time
Today, 15:23
Joined
Jul 26, 2013
Messages
10,367
I had a weird issue with the OnCurrent event not firing yesterday.

In the end I copied the code, deleted it, saved and closed the form. Compact & Repair then reopened and created a new OnCurrent event.

Pasted the code back in and Bob was my uncle working again. Weird corruption problem.
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 15:23
Joined
Sep 12, 2006
Messages
15,634
I think Minty has the right idea - rebuild the form, and see if that fixes it.
 

Micron

AWF VIP
Local time
Today, 10:23
Joined
Oct 20, 2018
Messages
3,478
sometimes the connection can get lost, in which case clicking the ellipses on property sheet can re-establish it even though it takes you to the already existing event code.
 
Last edited:

fluid

Registered User.
Local time
Today, 07:23
Joined
Nov 27, 2008
Messages
81
I applied Minty's tips, and Isladog's tips. They were both great ideas. And following the steps in IslaDogs's tips found quite a few glitches in my code. So, overall it was good. However, those steps have not fixed the original problem.
Any other thoughts?
 

isladogs

MVP / VIP
Local time
Today, 15:23
Joined
Jan 14, 2017
Messages
18,207
Hmmm...
You've decompiled, fixed all the compile errors and created a new form!
Long shot but are there any missing references?
If none of those solutions fixed it, suggest you post a cut down version of your dB and someone can have a look at your code.
 

mike60smart

Registered User.
Local time
Today, 15:23
Joined
Aug 6, 2017
Messages
1,913
Hi

Your Form opens just fine to the First Record

See attached:-

Form.jpg
 

isladogs

MVP / VIP
Local time
Today, 15:23
Joined
Jan 14, 2017
Messages
18,207
When I open the form, the navigation control is initially blank though the first record is, as you say, displayed. Clicking anywhere on the form fixes the navigation control and it shows 1 OF 1153.

I also get the Can't go to the selected record error using the next button.
Can't see any buttons for first, last or previous.

Other than that am I seeing the errors you're describing?

Split forms can be problematic if you try to edit their functionality.
You could try the emulated split form created to overcome various issues with the Access version. See https://www.access-programmers.co.uk/forums/showthread.php?t=294421
 

isladogs

MVP / VIP
Local time
Today, 15:23
Joined
Jan 14, 2017
Messages
18,207
Found the issue. Several of your controls are locked and/or disabled.
This prevents navigation.
Change all to locked = NO. Suggest you also have Enabled =Yes
 

fluid

Registered User.
Local time
Today, 07:23
Joined
Nov 27, 2008
Messages
81
Found the issue. Several of your controls are locked and/or disabled.
This prevents navigation.
Change all to locked = NO. Suggest you also have Enabled =Yes


I had those locked and disabled on purpose, I wanted them to be "Read-Only"

Am I not able to have locked and disabled controls on my form?
 

isladogs

MVP / VIP
Local time
Today, 15:23
Joined
Jan 14, 2017
Messages
18,207
You can't lock controls if you want to navigate between records in your split. form. It is the cause of your issues.
However, you could leave them disabled if you want.

EDIT You could prevent edits on the whole form by setting Allow Edits =NO. That won't prevent navigation
 

Users who are viewing this thread

Top Bottom