Default Value

mohammadagul

PrinceAtif
Local time
Today, 19:59
Joined
Mar 14, 2004
Messages
298
Question:
How Do I change the Default Value Property of A Check Box in a Table Through A Form ?
 
m,

Set field Check1 in Table1 to DefaultValue = False

Code:
For i = 0 To CurrentDb.TableDefs.Count - 1
   For j = 0 To CurrentDb.TableDefs(i).Fields.Count - 1
     If CurrentDb.TableDefs(i).Name = "Table1" And _
        CurrentDb.TableDefs(i).Fields(j).Name = "Check1" Then
           CurrentDb.TableDefs(i).Fields(j).DefaultValue = False
     End If
     Next j
   Next i

Wayne
 
Sorry to be a Pain but where do i put this code.

module or command button code or form
 
I have changed you code to the following

Private Sub cmdCI_Click()
On Error GoTo Err_cmdCI_Click

Dim i As Variant
Dim j As Variant

For i = 0 To CurrentDb.TableDefs.Count - 1
For j = 0 To CurrentDb.TableDefs(i).Fields.Count - 1
If CurrentDb.TableDefs(i).Name = "tblInvoices" And _
CurrentDb.TableDefs(i).Fields(j).Name = "Invoice" Then
MsgBox "Please Wait, Changes Are Being Made.", vbInformation, "Defining Invoice."
CurrentDb.TableDefs(i).Fields(j).DefaultValue = True
MsgBox "Congratulation!Changes Made Successfully", vbOKOnly, "Congratulation"

End If
Next j
Next i

Exit_cmdCI_Click:
Exit Sub

Err_cmdCI_Click:
MsgBox err.Description
Resume Exit_cmdCI_Click
End Sub

i want the user to see a wait message andthen a confimation or congratulation messages for successfully changing the default value. is the above code correct?
 

Users who are viewing this thread

Back
Top Bottom