This topic is locked

Inserting Fields ONLOAD from another table

12/10/2006 11:23:22 PM
ASPRunnerPro General questions
S
SDDivine author

This is my project.....
I have two tables...one called students and another called Reps. The project is password protected and the login and password is in the Reps table. When I open Students in list format, I would like to CALL and then DISPLAY certain information from the Reps table onto the top of the LIST page for Students.
As an example

[Reps] Representative Name

[Reps] Email address
When they visit the Students page, I'd like it to display the name and email address for that representative based upon the login password. Each Rep has a particular password stored in the REPS table along with the name and email address.
Using the ONLOAD in the events tab, what is the syntax that I should use to reach out and get this information?
I readily admit that I'm lost.
Steve Divine

J
Jane 12/11/2006

Steve,
here is a sample code:

Sub ListOnLoad()

'** Custom code ****

' put your custom code here

str = "select FieldName1, FieldName2 from [Reps]where UserName='" & Session("UserID") &"'"

Set rsTemp = server.CreateObject("ADODB.Recordset")

rsTemp.open str, dbConnection
Response.write "Representative Name " &rsTemp("FieldName1") &"
"

Response.write "Email address " &rsTemp("FieldName2") &"
"

End Sub



where FieldName1, FieldName2 are your actual field names of Representative Name and Email address fields.

UserName is your actual field name where user name is stored.

S
SDDivine author 12/11/2006

Steve,

here is a sample code:
where FieldName1, FieldName2 are your actual field names of Representative Name and Email address fields.

UserName is your actual field name where user name is stored.


I NEED MORE HELP....Can't get it to work....

This is the actual code that put in the Events
Sub ListOnLoad()

'** Custom code ****

' put your custom code here

str = "select REPNAME, R-email from [reps]where R-Login='" & Session("UserID") &"'"

Set rsTemp = server.CreateObject("ADODB.Recordset")

rsTemp.open str, dbConnection
Response.write "Representative Name " &rsTemp("REPNAME") &"
"

Response.write "Email address " &rsTemp("R-email") &"
"

End Sub
where reps is the table for the Representative and

R-Login is the identifiying user

REPNAME is their name

R-email is the email address
When I run this, I get this in response when i try to open the Student table
Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator to inform of the time the error occurred and of anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
Another question....

Assuming that it had actually worked....where would it have displayed this information and how would I have adjusted that?
Again, thank you for the help..this is a learning curve on the new program.
Steve Divine

J
Jane 12/12/2006

Steve,
this error occurs because you use incorrect characters in the field names in your SQL query.

Use [] brackets for these field names:

Sub ListOnLoad()

'** Custom code ****

' put your custom code here

str = "select [REPNAME], [R-email] from [reps] where [R-Login]='" & Session("UserID") &"'"

Set rsTemp = server.CreateObject("ADODB.Recordset")

rsTemp.open str, dbConnection
Response.write "Representative Name " &rsTemp("REPNAME") &"
"

Response.write "Email address " &rsTemp("R-email") &"
"

End Sub

S
SDDivine author 12/20/2006

ANOTHER QUESTION PLEASE....

How can I change the FONT and COLOR of the text that displays on the Form?
Is it possible to change the position of where this displays as well? I have it working correctly now, but it comes out in Times Roman 12 font and I'd like to change the font and color to highlight it.
Thanks

Steve Divine

Steve,

this error occurs because you use incorrect characters in the field names in your SQL query.

Use [] brackets for these field names:

J
Jane 12/21/2006

Steve,
to change font style and font color use following code:

Response.write "<FONT style="FONT-FAMILY: courier; COLOR: #cc3300;">Representative Name " &rsTemp("REPNAME") &"</FONT>
"

Response.write "<FONT style="FONT-FAMILY: Arial; COLOR: #333333;">Email address " &rsTemp("R-email") &"</FONT>
"


To change the position of where your text displays drag and drop Event OnLoad event in the Visual Editor tab.

S
SDDivine author 12/25/2006

THANK YOU VERY MUCH! <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=14071&image=1&table=forumreplies' class='bbc_emoticon' alt=':)' />

Steve Divine