PDA

View Full Version : Using recordsets to determine human species



Foosan
03-29-2022, 01:11 AM
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

arnelgp
03-29-2022, 04:49 AM
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