Consulting

Results 1 to 2 of 2

Thread: Using recordsets to determine human species

  1. #1
    VBAX Newbie
    Joined
    Mar 2022
    Posts
    1
    Location

    Using recordsets to determine human species

    I am an archaeology student. For an assignment, I have to create a program that lets you enter the cranial capacity (skull size) of a human and then tells you which human species it belongs to. I want to do this for 4 species, and have entered the minimum and maximum known cranial capacity for each of those species in a table in Access. As I want people to be able to change the values later if any new discoveries are made, I want the program to use the the table I put in Access. I am an absolute amature when it comes to coding and have never done anything like this before. I have searched for how to do this but I can't quite figure it out. Any tips?

    What I currently have:

    Private Sub Knop1_Click()
    Dim intTestCC As Integer
    Dim db As Database
    Dim strSQL As String
    Dim rs As DAO.Recordset
    Dim intInhoud As Integer
    intTestCC = (Int(Val(Me.textBox.Value)))
    Set db = CurrentDb
    strSQL = "select * from tblCChominids"
    Set rs = db.OpenRecordset(strSQL)
    End Sub
    Doing it like this for all of the values in the table also works, but I would really like for people to be able to change the values later.

    If intTestCC > 0 And intTestCC < 325 Then
    MsgBox "This hominid is not in our database, are you sure it's a human?"
    End If
    Last edited by Aussiebear; 03-29-2022 at 01:18 AM. Reason: Added code tags to supplied code

  2. #2
    you just use Dlookup() function:

    Private Sub Knop1_Click()
    Dim cnt As Integer
    Dim intTestCC As Integer
    intTestCC = (Int(Val(Me.textBox.Value & "")))
    cnt = DCount("1", "tblCChominids", intTestCC & " Between [minValueFieldName] And [maxValueFieldName]")
    if cnt < 1
       MsgBox "This hominid is not in our database, are you sure it's a human?"
    End If
    End Sub
    Last edited by Aussiebear; 03-29-2022 at 10:49 AM. Reason: Added code tags to supplied code

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •