Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing the RecordSource if Column = value

Status
Not open for further replies.

dr00bie

Programmer
Feb 19, 2004
108
US
It's me again... I have come across another problem. This question is for using Access ADP for reporting. I setup my application to run off of the username of the current user. Problem is that some of the users of the database enter data for other users. For an example, one of the ladies enters the data for 2 other people. I am currently at home, but couldn't quit thinking about it, so I won't be able to implement it until Monday. I will modify my database to the following,

ID auto-inc. int
PONum - varchar(10)
PODate - datetime
Vendor - varchar(40)
Description - varchar(75)
CardholderID - varchar(20)
RuntimeUserID - varchar(20) default N
Complete - bit
Carryover - bit
DiffRuntimeUser - bit

So the effect is that if DiffRuntimeUser = 1, then there is a different runtime user than the cardholder, whose name is in the RuntimeUserID.

Since multiple cardholders may be entered by 1 user, I need the get report button on the form to check for the value of DiffRuntimeUser, if it is 1, then I need to display a dropdown box with CardholderID as the value and CardholderName as the label,

SELECT DISTINCT C.CardholderID, CH.CardholderName
FROM CreditCardLog C INNER JOIN Cardholder CH ON C.CardholderID = CH.CardholderID
WHERE DiffRuntimeUser = fNTUser --the username of the current user

Then use the selected CardholderID value for the RecordSource below, with a conditional that looks at the DiffRuntimeUser bit field to change the RecordSource, something like below,

If rs("DiffRuntimeUser") = 1 Then
strSQL = "SELECT DISTINCT *
strSQL = strSQL & " FROM CreditCardLog
strSQL = strSQL & " WHERE RuntimeUserID = DropdownValue
Report.Recordsource = strSQL
Else
Report.Recordsource = Exec.SP
End If

I know ASP syntax very well, but am really lacking in my Access programming syntax. How would I accomplish these tasks?

As I said before, I will not be able to implement any suggestions until Monday, but wanted to get this out of my brain while it was fresh.

Thanks in Advance,
Drew
 
strSQL = strSQL & " WHERE RuntimeUserID = " & Me.DropdownValue

or

strSQL = strSQL & " WHERE RuntimeUserID = " & Forms!MyForm1!DropdownValue
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top