اذهب الي المحتوي
أوفيسنا

اختيار عشوائي


toofe

الردود الموصى بها

بسم الله الرحمن الرحيم 

 لدي قاعدة بيانات تحتوي على معرف واسم و لدي كود يعمل راندوم بعد اختيار قيمة الراندوم من تيكست بوكس وكل هذا يعمل على المعرف وهو (الاي دي) احتاج عمل نفس الكود ولكن على الاسماء والكود كالتالي  وتعذر علي رفع قاعدة البيانات لصغر حجم الملفات المرفوعة ارجو المساعدة قدر الامكان مع الشكر الجزيل

Dim SQL As String
   Dim sWhere As String
   Dim iCount As Integer
   Dim i As Integer
   Dim j As Integer
   Dim iSelectHowMany As Integer
   Dim aSel() As Integer
   Dim IsRepeated As Boolean
   Dim vItem As Variant
   Dim rc As Recordset
   Dim x As Integer
    Set rc = CurrentDb.OpenRecordset("test")
    x = rc.RecordCount
   
    If IsNull(Me.Text12) Or Me.Text12 = 0 Then
       re = MsgBox(not null, 0, xxx)
       Else
    If Text12.Value > x Then
    re = MsgBox(not null, 0, xxx)
  Else
    
     iSelectHowMany = Text12.Value
     SQL = "Select * from [test]"
   
   ' Find number of records in table.
   iCount = DCount("*", "test")
   
   Randomize
   i = Int(iCount * Rnd()) + 1
   ReDim aSel(0)
   aSel(0) = i
     
   j = 1
   Do While j < iSelectHowMany
     IsRepeated = False
     Do While Not IsRepeated
       i = Int(iCount * Rnd()) + 1
         
       For Each vItem In aSel
         If vItem = i Then
           IsRepeated = True
           Exit For
         End If
       Next vItem
     
       If Not IsRepeated Then
         ReDim Preserve aSel(j)
         aSel(j) = i
         j = j + 1
         Exit Do
       End If
     Loop
   Loop
      
   For Each vItem In aSel
     sWhere = sWhere & ", " & vItem
   SQL = SQL & " where [ID] in (" & Mid(sWhere, 2) & ")"
    'MsgBox SQL
   Me.test.Form.RecordSource = SQL
   End If
End If
End Sub

 

رابط هذا التعليق
شارك

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

زائر
اضف رد علي هذا الموضوع....

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • اضف...

Important Information