[solved] how to show sub datasheet on form?
hi,
i wish to load a sub datasheet on form based on a value of a textbox (in that form also)
i use the following code
the sPunchCard is a textbox which contained the value of the wanna loaded table name.
VB Code:
Private Sub Form_Current()
If Len(sPunchCard) < 2 Then
Exit Sub
Else
If table_exists(sPunchCard) = True Then
SSubForm.Visible = True
SSubForm.Locked = True
SSubForm.SourceObject = "TABLE." & sPunchCard
Else
SSubForm.Visible = False
End If
End If
End Sub
Public Function table_exists(tblName As String) As Boolean
Dim i As Integer
table_exists = False
For i = 0 To CurrentDb.TableDefs.Count - 1
If CurrentDb.TableDefs(i).Name = tblName Then
table_exists = True
Exit Function
End If
Next
End Function
the code functions well, but when it comes to the last record, and after use press the next record, it presents with an error box
Run-time error '94':
Invalid use of Null
anyone have any ideas?
Re: how to show sub datasheet on form?
sorry, i am a bit stupid today
i just need the
VB Code:
Private Sub Form_Current()
On Error Goto FormError
....
....
FormError:
Exit Sub