Help with Function:Return answer to the table

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Help, I have a function that will convert bytes to gb, mb etc. I am very
new to programming and writing functions and my issue is: I can call the
function and enter in my value and get the answer in the immediate window,
but how do I get that same answer to be written to a table automatically.

Example: Results in the immediate window
? SetBytes (79990845440)
74.50 GB

I would like to have this 74.50 GB written to a field in a access table:
Please give me some insight on how to proceed. I have done many searches with
no good result. Thanks
 
You can use an update query

UPDATE TableName SET TableName.FieldName = SetBytes ([FieldName2])

The parameter sent to the function is another field from the table.
 
Another option will be to open a recordset

Dim MyDB as database, MyRec as Recordset

Set MyDB=codedb()
Set MyRec=MyDB.OpenRecordset("TableName")
MyRec.Edit
MyRec!FieldName= SetBytes (ParamSent)
MyRec.Update
 
You don't need a function at all! All you need is a field named MyGigaByte
in your table. You include this field on your form and make it hidden (not
visible). You add an unbound textbox named EnterValueHere on your form. This
is where you type in 79990845440. Then you put the following code in the
Afterupdate event of that textbox:
Me!MyGigaByte = Me!EnterValueHere * <your formula for conversion>
74.50 will get saved to the table!
 
Back
Top