Hey,
I'm new here so hello all :D
So recently i have been working on a code which is supposed to search through one or two tables in access and return the results in a datasheet or list view in another form so that when the user selects one of the returned values that a full list of details for that record can be opened up. but one of the problems is that out of the 4 fields not all of the fields have to be entered and depending on the fields entered the search is different.
So here is the pseudo code (where A= LoanID, B = ApplicantID, C = Name, D = DOB)
open tblLoan
move to first
If A <> Nullthen
For I = 1 to EOF of tblLoan
If A = x.LoanID then
Exit loop
end if
end for
If x.LoanID = EOF LoanID Then
If x.LoanID <> A then
Valid = 0
Else
Valid = 1
end if
Else
Valid = 1
End if
If Valid = 1 then
If B <> Nullthen
If B = ApplicantID of tblApplicant
Valid = 0
else
Valid = 1
end if
end if
If C <> Nullthen
If C = Name of tblApplicant
Valid = 0
else
Valid = 1
end if
end if
If D <> Nullthen
If D = DOB of tblLoan
Valid = 0
else
Valid = 1
end if
end if
End if
which is where i got up to, i stopped here cause i realized that if i were to do it there would be a very lengthy code. Specially since there a few more searches like this in this system.
So after google this for a bit i found that there is a way to use sql so that i wouldn't need most of the loops and if statements. But i couldn't find out exactly how to do it.
If someone who reads this could you suggest if there is a simpler way to do this using loops and if condition or a example for the sql way
Thank you,
Happy New Year,
dragondude28.
I'm new here so hello all :D
So recently i have been working on a code which is supposed to search through one or two tables in access and return the results in a datasheet or list view in another form so that when the user selects one of the returned values that a full list of details for that record can be opened up. but one of the problems is that out of the 4 fields not all of the fields have to be entered and depending on the fields entered the search is different.
So here is the pseudo code (where A= LoanID, B = ApplicantID, C = Name, D = DOB)
open tblLoan
move to first
If A <> Nullthen
For I = 1 to EOF of tblLoan
If A = x.LoanID then
Exit loop
end if
end for
If x.LoanID = EOF LoanID Then
If x.LoanID <> A then
Valid = 0
Else
Valid = 1
end if
Else
Valid = 1
End if
If Valid = 1 then
If B <> Nullthen
If B = ApplicantID of tblApplicant
Valid = 0
else
Valid = 1
end if
end if
If C <> Nullthen
If C = Name of tblApplicant
Valid = 0
else
Valid = 1
end if
end if
If D <> Nullthen
If D = DOB of tblLoan
Valid = 0
else
Valid = 1
end if
end if
End if
which is where i got up to, i stopped here cause i realized that if i were to do it there would be a very lengthy code. Specially since there a few more searches like this in this system.
So after google this for a bit i found that there is a way to use sql so that i wouldn't need most of the loops and if statements. But i couldn't find out exactly how to do it.
If someone who reads this could you suggest if there is a simpler way to do this using loops and if condition or a example for the sql way
Thank you,
Happy New Year,
dragondude28.