Home > Software engineering >  How to use in vb MSHFlexGrid control will be displayed in the access database content
How to use in vb MSHFlexGrid control will be displayed in the access database content

Time:09-19

How to use in vb MSHFlexGrid control will be displayed in the access database content??????

CodePudding user response:

Use ADO to remove the record
Then the set mshflexgrid1. Can you=rs

CodePudding user response:


Modify the code
 Private Sub Command1_Click () 
'confirm modify
For I=0 To 8
If Text1 (I). The Text="" Then
MsgBox "you didn't enter the first" & amp; I + 1 & amp; "Text box of the data, please enter!" , 16, "error!"
The Exit Sub
End the If
Next I
If IsDate (Text1 (3). The Text)=False Then
MsgBox "the production time is not date you input, please input again!" , 16, "error!"
The Exit Sub
End the If
If IsDate (Text1 (4). The Text)=False Then
MsgBox "the sales time not the date you input, please input again!" , 16, "error!"
The Exit Sub
End the If
If IsNumeric (Text1 (7). The Text)=False Then
MsgBox "the number you entered is not a number, please input again!" , 16, "error!"
The Exit Sub
End the If
Adodc1. RecordSource="Select * From sales table Where ID=" & amp; AID & amp; "
"Adodc1. Refresh
Adodc1. You. Fields (" name ")=Text1 (0). The Text
Adodc1. You. Fields (" type ")=Text1. (1) the Text
Adodc1. You. Fields (" batch ")=Text1. (2) the Text
Adodc1. You. Fields (" production time ")=Text1. (3) the Text
Adodc1. You. Fields (" selling time ")=Text1. (4) the Text
Adodc1. You. Fields (" sales personnel ")=Text1. (5) Text
Adodc1. You. Fields (" buy factory ")=Text1 (6). The Text
Adodc1. You. Fields (" number ")=Val (Text1 (7). The Text)
'Adodc1. You. Fields (" code ")=Text1 (8). The Text' commodity code cannot modify
Adodc1. You. Update
MsgBox "congratulations! This record has been modified!" , 64, "success!"
Unload Me
MSH control operation instance. The Show
End Sub

Add code
 Private Sub Command2_Click () 
'confirm add
For I=0 To 8
If Text1 (I). The Text="" Then
MsgBox "you didn't enter the first" & amp; I + 1 & amp; "Text box of the data, please enter!" , 16, "error!"
The Exit Sub
End the If
Next I
If IsDate (Text1 (3). The Text)=False Then
MsgBox "the production time is not date you input, please input again!" , 16, "error!"
The Exit Sub
End the If
If IsDate (Text1 (4). The Text)=False Then
MsgBox "the sales time not the date you input, please input again!" , 16, "error!"
The Exit Sub
End the If
If IsNumeric (Text1 (7). The Text)=False Then
MsgBox "the number you entered is not a number, please input again!" , 16, "error!"
The Exit Sub
End the If
Adodc1. RecordSource="Select * From sales table"
Adodc1. Refresh
Adodc1. You. AddNew
Adodc1. You. Fields (" name ")=Text1 (0). The Text
Adodc1. You. Fields (" type ")=Text1. (1) the Text
Adodc1. You. Fields (" batch ")=Text1. (2) the Text
Adodc1. You. Fields (" production time ")=Text1. (3) the Text
Adodc1. You. Fields (" selling time ")=Text1. (4) the Text
Adodc1. You. Fields (" sales personnel ")=Text1. (5) Text
Adodc1. You. Fields (" buy factory ")=Text1 (6). The Text
Adodc1. You. Fields (" number ")=Val (Text1 (7). The Text)
Adodc1. You. Fields (" code ")=Text1 (8). The Text
Adodc1. You. Fields (" code 0 ")=Val (Label1. Caption)
Adodc1. You. Update
MsgBox "congratulations! A new record has been stored!" , 64, "added successfully!"
Unload Me
MSH control operation instance. The Show
End Sub

Delete the code
 Private Sub Command3_Click () 
'confirm delete
If AID=0 Then
MsgBox "you have no choice to delete records, please click on the above list need to delete the record!" , 16, "error!"
The Exit Sub
End the If
If MsgBox (" do you really want to delete this record?" , 33, remove confirmed! "" )=1 Then
Adodc1. RecordSource="Select * From sales table Where ID=" & amp; AID & amp; "
"Adodc1. Refresh
Adodc1. You. Delete
MsgBox "congratulations! This record has been deleted!" , 64, "deleted successfully!"
Unload Me
MSH control operation instance. The Show
End the If
End Sub

Startup code

 Private Sub Form_Load () 
For I=0 To 8
Text1 (I). The Text=""
Next I
Label1. Caption=""
Adodc1. The ConnectionString="Provider=Microsoft. ACE. The OLEDB. 12.0; Data Source="& amp; App. The Path & amp; New database "\. Accdb; The Jet OLEDB: Database Password=;"
Adodc1. RecordSource="Select * From sales table"
Adodc1. Refresh
Dim SST As Integer
SST=Adodc1. You. RecordCount
MSHFlexGrid1. Clear
MSHFlexGrid1. Visible=True
With MSHFlexGrid1
The Cols=10
. The Rows=SST + 1
. TextMatrix (0, 0)="ID", "
. TextMatrix (0, 1)="name"
TextMatrix (0, 2)="models"
TextMatrix (0, 3)="batch"
TextMatrix (0, 4)="production time"
TextMatrix (0, 5)="selling time"
TextMatrix (0, 6)="salesman"
. TextMatrix (0, 7)="buy factory"
TextMatrix (0, 8)="number"
. TextMatrix (0, 9)="encoding"
ColWidth (0)=600
ColWidth (1)=1200
ColWidth (2)=1000
ColWidth (3)=800
ColWidth (4)=1000
ColWidth (5)=1000
ColWidth (6)=800
ColWidth (7)=1400
ColWidth (8)=600
ColWidth (9)=800
For I=1 To SST
TextMatrix (I, 0)=Adodc1. You. Fields (" ID ")
TextMatrix (I, 1)=Adodc1. You. Fields (" name ")
TextMatrix (I, 2)=Adodc1. You. Fields (" type ")
TextMatrix (I, 3)=Adodc1. You. Fields (" batch ")
TextMatrix (I, 4)=Adodc1. You. Fields (" production time ")
TextMatrix (I, 5)=Adodc1. You. Fields (" selling time ")
TextMatrix (I, 6)=Adodc1. You. Fields (" sales personnel ")
TextMatrix (I, 7)=Adodc1. You. Fields (" buy factory ")
TextMatrix (I, 8)=Adodc1. You. Fields (" number ")
TextMatrix (I, 9)=Adodc1. You. Fields (" code ")
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related