Hi All!
I am new to writing VBA code. So new that this is my first time writing anything. I have been able to find information on what I am trying to do but I get to a point and I have no clue what I need to write next.
So this is what I am trying to do: I have a form (CompanyF) that contains a text box called CompanyID, a text box called Company and an unbound listbox (companyloans) in which the row source is from a query. Companyloans contains the information of the Company's loan (amount, date started, type). When I double click on the Company's loan info I open another form (LoanF) that shows me their loan information (like loan id, interest rate, there are some subforms with loan schedule and such). If each company only had one loan it wouldn't be a problem but there are a few company's that have more than one loan. The code that I put in there will open the LoanF form but it won't take me to that specific loan. It will allow me to look at all the company's loans but I will have to use the arrows to move to each loan and I would rather double click on the loan info and go straight to that record.
I found and used the following code to get to that point:
Private Sub companyloans_DblClick(Cancel As Integer)
If Not Me.NewRecord Then
DoCmd.OpenForm "LoanF", _
WhereCondition:="CompanyID=" & Me.CompanyID
End If
End Sub
The row source for the listbox is a query and is as follows:
SELECT LoansForCurrentCompanyQ.LoanID, LoansForCurrentCompanyQ.CompanyID, LoansForCurrentCompanyQ.LoanAmount, LoansForCurrentCompanyQ.StartDate, LoansForCurrentCompanyQ.Description
FROM LoansForCurrentCompanyQ;
I understand I told it just show the loan records for that CompanyID but I don't know how to tell it to go to the LoanID for the loan I want to look at.
I would very much appreciate any guidance!! My books and research are just confusing me more.