Blanc form

Vulcan1500

Registered User.
Local time
Today, 12:47
Joined
Nov 13, 2007
Messages
143
The problem is: When I delete all the records in the table 'Invoice' then the option group of the form does not show up. I have no idea why. As far as I know there is no reason that an empty 'invoice' table should influence the option group. Can on of you help me?

I'm using already some time my database in MS Access 2003 for invoicing purposes. Front and backend are separated. From the menu I can push a button and a form opens, which gives me 4 options to select the paper to print the invoice (e.g. blanc, pre-printed, ...) on. Either the default option or the by the user selected option is stored in a table in the frontend for future use. The code in the 'on open event' of the form is:

Code:
Private Sub Form_Open(Cancel As Integer)
Dim db As DAO.Database
Dim td As DAO.TableDef
Dim fld As DAO.Field
Dim rs As DAO.Recordset
Set db = CurrentDb()
If TableExists("EigenaarDruktAfOp") Then
Set rs = db.OpenRecordset("EigenaarDruktAfOp")
optAfdrukkenOp = Nz(rs("AfdrukkenOp").Value, "")
Else
optAfdrukkenOp = 1
'create table EigenaarDruktAfOp with field AdrukkenOp
Set td = db.CreateTableDef("EigenaarDruktAfOp")
With td
Set fld = .CreateField("AfdrukkenOp", dbSingle)
.Fields.Append fld
End With
db.TableDefs.Append td
'store optAfdrukkenOp
Set rs = db.OpenRecordset("EigenaarDruktAfOp")
rs.AddNew
rs!AfdrukkenOp = optAfdrukkenOp
rs.Update
End If
rs.Close
db.Close
Set rs = Nothing
Set fld = Nothing
Set td = Nothing
Set db = Nothing
End Sub

The code of the function TableExists is as follows:

Code:
Public Function TableExists(TableName As String) As Boolean
Public Function TableExists(TableName As String) As Boolean
'Checks for the existence of a table and returns true if table exists
Dim db As DAO.Database
Dim td As DAO.TableDef
TableExists = False
Set db = CurrentDb
For Each td In db.TableDefs
If td.Name = TableName Then
TableExists = True
Exit Function
End If
Next td
End Function

Normal form and blanc form are attached.
 

Attachments

  • ScreenHunter_01 Mar. 26 13.41.gif
    ScreenHunter_01 Mar. 26 13.41.gif
    5.6 KB · Views: 115
  • ScreenHunter_02 Mar. 26 13.42.gif
    ScreenHunter_02 Mar. 26 13.42.gif
    3.8 KB · Views: 117
If the form is bound to the table then it will do that. If you don't have to bind it to the table (which from looking at your screenshots would be fine) then it won't disappear like that.
 
This occurs when there are no records in the RecordSource and the no records can be added.

Deleting all the records in the table accounts for the first condition. The second condition can be caused by a number of things, such as AllowAdditions being set to No or the underlying RecordSet being Read-Only.
 
it can also be caused by a non-updateable recordset

and note that you cant use nz to test values. the values arent nulls - they are UNDEFINED - which is a different thing
 

Users who are viewing this thread

Back
Top Bottom