shakiba گفت:درسته
اكسس تمام اطلاعاتي كه از فرم وارد ميشه را ذخيره ميكنه
منم در اكسس يه جدول ساختم و اون فيلهايي كه ميخواستم را قرار دادم كه بعد از وي بي اون باكس ها را به فبلدهاي جدول اكسس كانكت كنم.
ولي نميدونم چرا تا ميام نام جدول را بزنم ارور ميده
Private Sub cmdBrowse_Click()
' Set CancelError is True
CommonDialog2.CancelError = True
On Error GoTo ErrHandler
' Set flags
CommonDialog2.Flags = cdlOFNHideReadOnly
' Set filters
CommonDialog2.Filter = "Microsoft Access Database (*.mdb)|*.mdb|All Files (*.*)|*.*"
' Specify default filter
CommonDialog2.FilterIndex = 1
' Display the Open dialog box
CommonDialog2.ShowOpen
' Display name of selected file
dbFileName = CommonDialog2.FileName
display
cmdTable.Enabled = True
cmdField.Enabled = True
cmdAutoId.Enabled = True
List1.Selected(0) = True
List1.ListIndex = 0
Exit Sub
ErrHandler:
'User pressed the Cancel button
Exit Sub
End Sub
Public Sub display()
Set db = OpenDatabase(dbFileName)
' Display the attributes of the Northwind database's
' tables.
List1.Clear
'MsgBox "Attributes of tables in " & .Name & ":"
For Each tdf In db.TableDefs
If Not tdf.Name Like "MSys*" Then
List1.AddItem (tdf.Name)
Else
'MsgBox tdf.Name & "is System Table"
End If
Next tdf
End Sub
Private Sub cmdField_Click()
Dim tIndex As Integer
' Display the attributes of a TableDef object's
' fields.
List2.Clear
For Each tdf In db.TableDefs
If tdf.Name Like List1.Text Then
For Each fld In db.TableDefs(tIndex).Fields
List2.AddItem fld.Name
Next fld
End If
tIndex = tIndex + 1
Next tdf
'List2.Selected = 0
List2.ListIndex = 0
End Sub
Private Sub cmdTable_Click()
Dim tIndex1 As Integer
' Count the attributes of a TableDef object's
' fields.
iFieldCount = 0
For Each tdf In db.TableDefs
If tdf.Name Like List1.Text Then
For Each fld In db.TableDefs(tIndex1).Fields
iFieldCount = iFieldCount + 1
Next fld
End If
tIndex1 = tIndex1 + 1
Next tdf
rsFileName = List1.Text
frmTable.Show
End Sub
Public Sub Form_Load()
' By making it public makes it easier to refresh
Set dbConn = New Connection ' Prepares the
' Connection
dbConn.CursorLocation = adUseClient
dbConn.Open "PROVIDER=Microsoft.Jet.OLEDB.3.51;Data Source = Database.mdb;"
' Enter the database name. This sets the db and
' uses the jet database engine to connect to the
'db
Set recSet = New Recordset 'sets the recordset
recSet.Open "Select * from Tables Order by Field ", dbConn, adOpenStatic, adLockOptimistic
'sql connecting recordset, and sets the sort by
'the field name you enter.
'Also NOTE: for more control replace the wildcard
' (*) with fieldName1, fieldName2, fieldName3.......
' For the other options you replace order bf field
' with where field = "string", where field in "string",
' or group by "string" * Where string = the requirement you want to use
' Such as "group by Subject"
If recSet.BOF = False And recSet.EOF = False Then
'if there is an entry
recSet.MoveFirst ' moves to first entry
End If
recMove = True
recAdd = True
Call Display_fields
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
Dim str As String
Dim str1 As String
str = "qwertyuiop[]';lkjhgfdsazxcvbnm,./\|QWERTYUIOP{}ASDFGHJKL:?><MNBVCXZ~!@#$%^&*()_+=-" & Chr(34)
If KeyAscii > 26 Then
If InStr(str, Chr(KeyAscii)) <> 0 Then
KeyAscii = 0
End If
End If
End Sub