Unbound subform has no (null) records, form stays blank

Rx_

Nothing In Moderation
Local time
Today, 03:58
Joined
Oct 22, 2009
Messages
2,803
The unbound Parent form has a listbox (SQL Server) , the selection updates the SubForm with a primary key ID.
The Subform is a ReadOnly view from an Oracle Linked table. It populates with a Select * From Oracleview where ID = listboxID
The code is at the link shown below
update: The subform uses textboxes linked to the read-only record.

The main form can populate, no problem. However the SubForm data source is either populated OR is Null.

If it is Null, the subform stays blank.
Two Objectives:
1. Set a boolean variable flag in the parent (main form) that subform record exist or that it is null. e.g. Parent obtain recordset count property from Sub form
2. Display the subform with blanks.

http://www.access-programmers.co.uk/forums/showthread.php?t=279791
 
Last edited:
mysubform.form.recordsource="SELECT..."
if mysubform.Form.Recordset.RecordCount=0 then
...
...

note the subform cannot display blanks since there is no record to display. In addition to my suggestion on the previous link, if recordcount is 0 then you could use

mysubform.form.recordsource="SELECT... 0 AS ID, "No Record" AS myDesc1, "no record" AS myDesc2..."

You would need to complete for all fields displayed otherwise you will get a #Name error on the display
 
SPOT ON ---- as usual!
Found some code that would display the empty text box in case of a zero record.
Will keep that in my hip pocket if the customer insist.
Thanks again twice in one day.

ONE MORE QUESTION!
I am trying to keep the code for record count in the Parent form to seet a Boolean (a.k.a your If Then statement)
The link to the Sub Form is Oracle across a distance, averate time to respond is 3 seconds.
Tried the code in the Listbox After update that sets the Subform Recordsource.

My indication is that the SubForm is taking 3 seconds to open - so it isn't at that point in code.
Is there another place (Event wise) that might be better to poll the Recordcount in the Sub Form?
 
Last edited:

Users who are viewing this thread

Back
Top Bottom