473,473 Members | 1,846 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Is there a way to load individual text boxes with coded SQL statements Please?

54 New Member
I have a form that is used just to review previously saved records.(1 record at a time).

It also allows just a couple of fields to be updatable (in a given record)and resaved.

I load all the text boxes in this this form simply by creating a recordset in the forms Load event procedure.
It then populates the fields using... say [txtModelID = rs!ModelID].
This works fine.

But in the table that the recordsourse draws from there is only a customerID field and no CustomerFirstName or CustomerLastName fields; these are in the Customers Table which has matching CustomerID numbers.

what I would like to know is once the recordsource has been created how can I write an SQL statement in the Form Load event procedure the will do something like ..
SELECT CustomerName From tblCustomers Where tblCustomers.CustomerID = rs!CustomerID
then have that sql statement load the relevant customers name into the txtCustomer textbox on the form. Same with a few other fields that are on the form but not in the table that the Recordset draws from.

I do not want to use a stored query (with criteria) to populate the form...I tried that and although it worked fine to populate all the required fields, if the user modified the three fields that are updatable, then clicked the SAVE button (which would create a recordset and only write those 3 fields back into the table) , every time you did go to do a SAVE a message would come up saying something like ... "Another user has modified the record, do you wish to Write, Drop or Save your changes to the clipboard" which is untrue as there is only one user on any given PC. So I would like to avoid that if at all possible. Even if it takes 3 or 4 SQL statements to get the relevant text boxes loaded.

Many thanks again for all the help.
Jan 13 '07 #1
5 1440
NeoPa
32,556 Recognized Expert Moderator MVP
Zaphod,
It seems like you're trying to work around Access rather than using it to do your work for you.
A form with a single record is handled ok in Access but doesn't need a special command button to trigger the save. Any movement off the current record will do that automatically (Obviously if you wanted to restrict it to a command button then you could avoid showing the record navigation controls and have some code in the button to move off then back on to the record).
If you wanted to restrict the fields that were updatable then locking them would do that for you.
In short, I very strongly recommend working with Access rather than around it.
Jan 13 '07 #2
MMcCarthy
14,534 Recognized Expert Moderator MVP
I have a form that is used just to review previously saved records.(1 record at a time).

It also allows just a couple of fields to be updatable (in a given record)and resaved.

I load all the text boxes in this this form simply by creating a recordset in the forms Load event procedure.
It then populates the fields using... say [txtModelID = rs!ModelID].
This works fine.

But in the table that the recordsourse draws from there is only a customerID field and no CustomerFirstName or CustomerLastName fields; these are in the Customers Table which has matching CustomerID numbers.

what I would like to know is once the recordsource has been created how can I write an SQL statement in the Form Load event procedure the will do something like ..
SELECT CustomerName From tblCustomers Where tblCustomers.CustomerID = rs!CustomerID
then have that sql statement load the relevant customers name into the txtCustomer textbox on the form. Same with a few other fields that are on the form but not in the table that the Recordset draws from.
I would suggest creating a second recordset. Make a select query in that recordset that would return all the field values you need including the CustomerID.

Once the relevant CustomerID is reached by the original recordset you could match it using something like ...
Expand|Select|Wrap|Line Numbers
  1. rs2.FindFirst "[CutomerID]=" & rs1!CustomerID
You can use an unbound form and make the relevant textboxes equal to the resulting record like

Expand|Select|Wrap|Line Numbers
  1. Me.txtCustID = rs2!CustomerID

Mary
Jan 13 '07 #3
ZaphodBBB
54 New Member
Hi and thanks again for the replies

Yes you are right NeoPa I probably am working around access , unfortumatly the only time I know it is when i get advised by some one here like yourself!

Thanks Mary I never knew you could open two recordsets at the same time..I'll give it a try and see how I go thanks.

Mike
Jan 17 '07 #4
ZaphodBBB
54 New Member
Hi Mary

Just tried as you suggested and it worked well!!

Used:
strSQL = "SELECT CompanyName,Department,ContactFirstName,ContactLas tName " & _
"FROM tblCustomers Where tblCustomers.CustomerID =" & rs!CustomerID

Then
Set rs2 = db.OpenRecordset(strSQL, dbOpenDynaset)

After first having dimmed the strSQL and the two Recordsets.

So yet again, thanks to you and NeoPa for all the assistance given!
Jan 17 '07 #5
MMcCarthy
14,534 Recognized Expert Moderator MVP
Hi Mary

Just tried as you suggested and it worked well!!

Used:
strSQL = "SELECT CompanyName,Department,ContactFirstName,ContactLas tName " & _
"FROM tblCustomers Where tblCustomers.CustomerID =" & rs!CustomerID

Then
Set rs2 = db.OpenRecordset(strSQL, dbOpenDynaset)

After first having dimmed the strSQL and the two Recordsets.

So yet again, thanks to you and NeoPa for all the assistance given!
That's great.

Glad it worked out for you.

Mary
Jan 17 '07 #6

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

Similar topics

19
by: dmiller23462 | last post by:
Hi guys....I have absolutely NO IDEA what I'm doing with Javascript but my end result is I need two text boxes to stay hidden until a particular option is selected....I've cobbled together the...
4
by: Enterprise | last post by:
Hi, I have 25 text boxes in a form. Lets say TB1 through TB25 are the Names of the boxes. They have no controll sources. I want to be able to check whether the text box is empty. Is there anyway I...
4
by: ckpoll2 | last post by:
Hello, I have a report and am having a hard time summing some numbers. In the detail section of the report, I have 2 text boxes that have IIF statements in them. These IIF statements return...
2
by: shank | last post by:
I posted this in an HTML forum, but I think it's going to take some scripting to act as I want to act. I have a form with multiple records. My intention is to have the user click a checkbox for...
10
by: Gerhard | last post by:
Hi, all I run into the same problem on Access 2000 and 2003. Hopefully someone can replicate it – or not. 1. Create an unbound form – call it Form1. 2. Insert two unbound text boxes –...
5
by: rn5a | last post by:
Can someone please suggest me a text editor especially for DEBUGGING ASP scripts apart from Microsoft Visual Interdev? I tried using Visual Interdev & created a project but Interdev generates...
10
by: sara | last post by:
Hi - I have been struggling with solution ideas for this now for almost 2 weeks, and have not been able to figure this out. I have a user who creates a Purchase Order (tblPOData). In some...
1
by: Dennis | last post by:
I've noticed some old posts regarding this issue; but nothing recently and no resolutions in the old postings. Its almost hard for me to believe that this wouldn't be fixed by now. I am using...
9
by: RICHARD BROMBERG | last post by:
Please bear in mind that I am a newbie. I am posting this question a second time because the responses to my earlier post were a little wide of the mark. So, here goes: I am using Access 2000...
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...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.