View Full Version : FIND Speciffic record and USE it using VBA


voskouee
05-08-2007, 01:42 AM
I have a table with country names and currencies. I am using VBA and am opening a recordset and i want to FIND AND USE use only one speciffic record from that recordset. how do i do it?

any ideas?

i know i can use the find method of the recordsets... how can i use it after i find it.. how do i declare it?

this will use all the rates in the list... for the first one only what do i do?

Set RsType = CurrentDb.OpenRecordset("SELECT SOBP,SOBPDEBIT FROM RFGDebitNotes ;")
Set RsTbl = CurrentDb.OpenRecordset("SELECT * FROM " & RsType!sobpdebit & " ;")
Set RsCur = CurrentDb.OpenRecordset("SELECT SOBP, CUR from CURRFG;")

Do While Not RsType.EOF

DoCmd.SetWarnings (False)

strDBCura = "Update " & RsType!sobpdebit & " set DebitDBN = Debits * " & Val(RsCur!CUR) & ";"

Bodisathva
05-08-2007, 03:56 AM
Replace the RsCur with a DLookup...

strDBCura = "Update " & RsType!sobpdebit & " set DebitDBN = Debits * " & DLookup("CUR","CURRFG", "SOBP = '" & RsType!SOBP & "';"

I wrapped the criteria of the DLookup with single quotes, assuming it was a string, if it's a number, remove them. Alternatively, you can also establish the RsCur recordset within the loop as long as you add the WHERE critera.

voskouee
05-08-2007, 04:28 AM
can i replace the SOBP = with a speciffic value?

where does the column closes?

Bodisathva
05-08-2007, 05:43 AM
can i replace the SOBP = with a speciffic value?
yes. assuming you mean DLookup("CUR","CURRFG", "SOBP = 5") where does the column closes?oops:o

strDBCura = "Update " & RsType!sobpdebit & " SET DebitDBN = Debits * " & DLookup("CUR","CURRFG", "SOBP = '" & RsType!SOBP & "')" & ";"

voskouee
05-08-2007, 10:18 PM
Thank you so much my friend.. and this is not the first time you helped me..

i appreciate that you are sharing your knowledge..

Bodisathva
05-09-2007, 03:41 AM
you're welcome :)

a_20120
07-02-2007, 11:24 PM
I dont know what is the problem:
Me.STFamily.Value = DLookup("[ST_Family]", "STUDENT", "[ST_ID] = Me.cboStudent ")

ST_ID is numeric type

a_20120
07-02-2007, 11:29 PM
For numerical values:

DLookup("FieldName", "TableName", "Criteria = " & forms!FormName!ControlName)

This helped me