473,387 Members | 1,553 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.

Need help!

I am trying to write a code so that when the user click on an account in the list box, it will search for a record in the table and dispay the record, if there is no record found, display the "No record on file " message. it works well with one account, but when I have 2 accounts in the list box, when a user click on the second account in the list box, the form display the data, but the error message still pop up saying "no record on file for the 1st account). Here is my code. Anybody has any idea?
Thanks a lot!

Dim db As Database
Dim rst As Recordset
Dim stLinkCriteria As String

'Open form and carry account number over first
stLinkCriteria = "[CVACCTNO]=" & Me![txtAcctNo]
DoCmd.OpenForm "frmIDX", , , stLinkCriteria
[Forms]![frmIDX]![txtPtName] = Me.txtPtName

'Find if record is exit. Find from beginning of recordset to ending of recordset
Set db = CurrentDb
Set rst = db.OpenRecordset("tblIDX", dbOpenDynaset)
rst.FindFirst "[ACCTNOIDX] = " & Me![CVACCTNO] & ""

If rst.NoMatch Then
MsgBox "No IDX record was found under this account number: " & CVACCTNO & "", vbOKOnly, "No Record On File"
DoCmd.Close acForm, "frmIDX", acSaveNo
Else
stLinkCriteria = "[CVACCTNO]=" & Me![txtAcctNo]
DoCmd.OpenForm "frmIDX", , , stLinkCriteria
[Forms]![frmIDX]![txtPtName] = Me.txtPtName
End If
Nov 2 '06 #1
2 1074
PEB
1,418 Expert 1GB
Hi,

I don't understand why do you use this line:
[Forms]![frmIDX]![txtPtName] = Me.txtPtName
Why do you eplace the value [Forms]![frmIDX]![txtPtName] with Me.txtPtName???
Nov 4 '06 #2
MMcCarthy
14,534 Expert Mod 8TB
I am trying to write a code so that when the user click on an account in the list box, it will search for a record in the table and dispay the record, if there is no record found, display the "No record on file " message. it works well with one account, but when I have 2 accounts in the list box, when a user click on the second account in the list box, the form display the data, but the error message still pop up saying "no record on file for the 1st account). Here is my code. Anybody has any idea?
Thanks a lot!
Firstly, you haven't closed your recordset. This will always cause problems.

Secondly, you're opening a form. Then checking a recordset and then trying to open the form again.

I don't understand what you're doing.

Also

rst.FindFirst "[ACCTNOIDX] = " & Me![CVACCTNO] & ""

indicated CVACCTNO is a string

However

stLinkCriteria = "[CVACCTNO]=" & Me![txtAcctNo]

indicates it's a number.

Can you explain in detail.

What is the record source of frmIDX is it simply tblIDX or a query based on that table. If so what is the query.

Why are you comparing two fields that seem to be in the same table (based on your code) ACCTNOIDX and CVACCTNO.
Nov 7 '06 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: mike | last post by:
Hello, After trying to validate this page for a couple of days now I was wondering if someone might be able to help me out. Below is a list of snippets where I am having the errors. 1. Line 334,...
5
by: John Flynn | last post by:
hi all i'm going to be quick i have an assignment due which i have no idea how to do. i work full time so i dont have the time to learn it and its due date has crept up on me .. As follows:...
0
by: xunling | last post by:
i have a question about answering ..... this topic is "need help" what do i have to write at te topic line, !after i have klicked the "answer message" button ive tried many possibilities,...
9
by: sk | last post by:
I have an applicaton in which I collect data for different parameters for a set of devices. The data are entered into a single table, each set of name, value pairs time-stamped and associated with...
7
by: Timothy Shih | last post by:
Hi, I am trying to figure out how to use unmanaged code using P/Invoke. I wrote a simple function which takes in 2 buffers (one a byte buffer, one a char buffer) and copies the contents of the byte...
15
by: Cheryl Langdon | last post by:
Hello everyone, This is my first attempt at getting help in this manner. Please forgive me if this is an inappropriate request. I suddenly find myself in urgent need of instruction on how to...
16
by: pamelafluente | last post by:
I am still working with no success on that client/server problem. I need your help. I will submit simplified versions of my problem so we can see clearly what is going on. My model: A client...
8
by: skumar434 | last post by:
i need to store the data from a data base in to structure .............the problem is like this ....suppose there is a data base which stores the sequence no and item type etc ...but i need only...
0
by: U S Contractors Offering Service A Non-profit | last post by:
Brilliant technology helping those most in need Inbox Reply U S Contractors Offering Service A Non-profit show details 10:37 pm (1 hour ago) Brilliant technology helping those most in need ...
20
by: mike | last post by:
I help manage a large web site, one that has over 600 html pages... It's a reference site for ham radio folks and as an example, one page indexes over 1.8 gb of on-line PDF documents. The site...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.