473,387 Members | 1,481 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Can I use FindFirst with multiple keys?

My first time to this group so please be kind.

Anyway I have this questionnaire that has two parts (2 tables). I
created a form for each of the tables and I am trying to make it so
that when I go to the other form I would go directly to the
corresponding record from the first form. And if it doesn't find a
corresponding record, it just opens a new record for data entry.

I have this piece of code from many months ago (from a yahoo group)
and it works great if I only have one record per patient person but now
my database has multiple records per patient and I haven't been able to
modify this code to search on two keys (say clinid and visit) instead
of just one (clinid).

Thanks,

Ryan
Private Sub Form_Load()

Dim rs As Object

If IsNull(clinid) = False Then

Set rs = Me.Recordset.Clone
rs.FindFirst "[clinid]= '" & OpenArgs & "'"

If Not rs.NoMatch Then
Me.Bookmark = rs.Bookmark
Else
DoCmd.GoToRecord , , acNewRec
Forms!md12_part2_form!clinid.SetFocus
End If

Set rs = Nothing
Else
Forms!md12_part2_form!clinid.SetFocus
End If

End Sub

Nov 13 '05 #1
4 3578

psydork wrote:
My first time to this group so please be kind.


How about something like:

rs.FindFirst Me.OpenArgs

where OpenArgs looks something like
"[clinid] = 5 AND [visit] = 32"

James A. Fortune

Nov 13 '05 #2
psydork wrote:
My first time to this group so please be kind.


How about something like:

rs.FindFirst Me.OpenArgs

where OpenArgs looks something like
"[clinid] = 5 AND [visit] = 32"

James A. Fortune

Nov 13 '05 #3
psydork wrote:
My first time to this group so please be kind.


How about something like:

rs.FindFirst Me.OpenArgs

where OpenArgs looks something like
"[clinid] = 5 AND [visit] = 32"

James A. Fortune

Nov 13 '05 #4
On 7 Dec 2004 13:07:17 -0800, "psydork" <rl**************@yahoo.com>
wrote:
My first time to this group so please be kind.

Anyway I have this questionnaire that has two parts (2 tables). I
created a form for each of the tables and I am trying to make it so
that when I go to the other form I would go directly to the
corresponding record from the first form. And if it doesn't find a
corresponding record, it just opens a new record for data entry.

I have this piece of code from many months ago (from a yahoo group)
and it works great if I only have one record per patient person but now
my database has multiple records per patient and I haven't been able to
modify this code to search on two keys (say clinid and visit) instead
of just one (clinid).

Thanks,

Ryan
Private Sub Form_Load()

Dim rs As Object

If IsNull(clinid) = False Then

Set rs = Me.Recordset.Clone
rs.FindFirst "[clinid]= '" & OpenArgs & "'"

If Not rs.NoMatch Then
Me.Bookmark = rs.Bookmark
Else
DoCmd.GoToRecord , , acNewRec
Forms!md12_part2_form!clinid.SetFocus
End If

Set rs = Nothing
Else
Forms!md12_part2_form!clinid.SetFocus
End If

End Sub

Hi

Format would be
rs.FindFirst "[clinid]= '" & aaa & "' AND [visit]='" & bbb & "'"
(aaa and bbb are variables) assuming both fields are text.

However you will need a way to pass both arguments between the forms.
Why not put the whole criterion into OpenArgs? eg

OpenArgs= "[clinid]= '" & aaa & "' AND [visit]='" & bbb & "'"

and then
rs.FindFirst OpenArgs

David

Nov 13 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Paul | last post by:
The 2 statements below work perfectly when using them individually. But when I try to concatenate them, they don't. rst.FindFirst " = " & OldQuoteNumber rst.FindFirst " Is Null" Can someone...
2
by: @ndy | last post by:
Hey, this is the situation. I have imported a table from Excel and know i must edit the saldo in the corresponding records tbl_Lignes. Impdata tbl_Lignes...
5
by: MLH | last post by:
I have a table I can open as table type recordset or a dynaset. Searching for a particular value in the table's main keyfield, which would be faster and less strain on the application......
1
by: bmshirey | last post by:
I have a program which manages various log files of multiple extensions. The program needs to delete files based on an age paramter and a file number limit paramter. So if files are older than say...
0
by: keri | last post by:
I have a calendar that currently shows the name of a customer in the correct date. However it does not show multiple appointments on the same day. I have worked out why it does this, but i am not...
3
by: developing | last post by:
Hello How do I specify multiple criteria for FindFirst or FindRecord (or anything else) that takes the criteria from a form. (text field and number field) edit: this will be in the after...
13
by: Eric IsWhoIAm | last post by:
I have four tables created so far: Courses, Instructors, Courses and Instructors (which shows the Course and Instructor Name fields, but holds their IDs since those are the keys), and Students....
25
by: Rick Collard | last post by:
Using DAO 3.6 on an Access 2002 database, I'm getting unexpected results with the FindFirst method. Here's the simple code to test: Public Sub FindIt() Dim db As Database, rs As Recordset...
4
by: raylopez99 | last post by:
Compound question: first, and this is not easy, if there's a way to detect multiple simultaneous key presses in C# let me know (in the below code, keys c and d being pressed simultaneously or...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.