Helo !
I have an access database with 11 fields to fill out for devices!
I want a modify option on the interface that i created that ask the user to select the serial number of the device that he want to modify and with a recordset the program copy the selected devices with the right serial number on an excel sheet and these devices will apear in a listbox in an userform named moddevice and the user select one of the devices!
I have this error message that appears: "L'indice n'appartient pas a la selection"
Here is my code:
Sub Imoddevice()
'==============================================================='
'Descritpif de la fonction:
' elle va dans un premier tems initialiser les feuilles excell qu'on utilise
' elle fait ensuite appelle à des inputbox pour avoir des
' informations complémentaires (ici modele du dispositif )
' et les met sur une feuille excel
' Ouvre la boite de dialogue pour modifier un dispositif
'---------------------------------------------------------------'
Dim basedonnee As Access.Application
'Dim refe As String
'refe = ThisWorkbook.Path & "\HMT_VBA.mdb"
Set basedonnee = GetObject("C:\Users\seb\Desktop\HANDKE Medizintechnik\Projets\GMAO avec access\HMT_VBA.accdb")
basedonnee.Visible = False
Dim modele As String, r As Integer, nb As Integer
Dim rst_SN As DAO.Recordset
' initialisation de la feuille excell conernée (on enlève toutes les information pour qu'elle
' soit réutilisable et que les données ne se supperposent pas)
Workbooks("HMT_VBA.xlsm").Sheets("search").Activate
nb = WorksheetFunction.CountA(Columns("a:a"))
If nb > 1 Then
r = 2
Do Until r = nb + 1
Range("A" & r).Value = Null
Range("B" & r).Value = Null
Range("C" & r).Value = Null
Range("D" & r).Value = Null
Range("E" & r).Value = Null
Range("F" & r).Value = Null
Range("G" & r).Value = Null
Range("H" & r).Value = Null
Range("I" & r).Value = Null
Range("J" & r).Value = Null
Range("K" & r).Value = Null
Range("L" & r).Value = Null
r = r + 1
Loop
End If
'Demande à l'utilisateur d'entrer le dispositif concerné
SN = InputBox("Enter SN", vbOKCancel)
If SN = "" Then
MsgBox " Error SN input "
Else
Set rst_SN = basedonnee.CurrentDb.OpenRecordset("select * from HMT_Database where Seriennummer='" & SN & "';")
Workbooks("HMT_VBA.xlsm").Sheets("search").Activate
r = 2
Do Until rst_SN.EOF
Range("A" & r).Value = rst_SN!ID
Range("B" & r).Value = rst_SN!Hersteller
Range("C" & r).Value = rst_SN!Geräteart
Range("D" & r).Value = rst_SN!Bezeichnung
Range("E" & r).Value = rst_SN!Seriennummer
Range("F" & r).Value = rst_SN!Artikelnummer
Range("G" & r).Value = rst_SN!Artikelnummer_AFS
Range("H" & r).Value = rst_SN!Wareneingang
Range("I" & r).Value = rst_SN!bgva3
Range("J" & r).Value = rst_SN!stk
Range("K" & r).Value = rst_SN!mtk
Range("L" & r).Value = rst_SN!Standort
r = r + 1
rst_SN.MoveNext
Loop
Load moddevice
moddevice.Show
rst_SN.Close
End If
Userinterface.Show
Thank you for your help!!!
Bookmarks