Question : Using DLookup in VBA code on Access Form

I am currently using 3 Dlookups on an access form but it slows the form down too much.  I would like to use the Dlookup in VBA that will be triggered when a "calc" button is clicked.  The form is a continuous form with 100 or so records.  I am able to write the code for the DLookup statement but am not sure how I can get it to cycle through all the records on the form.  Is this possible?

Answer : Using DLookup in VBA code on Access Form

Hi,

I would be using something like :

select left(type_desc,10)

to select the left most 10 characters. If you really want fixed length, then you might need to pad trailing spaces :

select left(type_desc+'          ',10)

if it can be NULL, then should really be checking the nullibility of the column :

select left(isnull(type_desc,'')+'          ',10)

or you can also convert or cast as CHAR(10) as well...

select convert(char(10), type_desc)

select cast(type_desc as char(10))

It would be nice to have a format command / function, but in SQL Server we dont. However, there are a few ways of handling it per above, just a little bit "raw".
Random Solutions  
 
programming4us programming4us