Results 1 to 11 of 11
  1. #1
    drunkenneo is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Jun 2013
    Posts
    199

    Form for foreign Exchange

    I have to design a table i know its piece of cake.



    Here i want user to continous form which wil be once in a month

    needed is

    EUR USD From To


    User will enter the line with values and the period with valid dates.

    Since its a continous form i need user to fill all the details compulsory, as user cannot close the form without it.

    Hw is it possible?

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Could set the fields as required in table then let Access nag the user if they try to leave the record with empty fields.

    And/Or use ValidationRule property of controls as well as form BeforeUpdate event to check if fields have values.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    drunkenneo is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Jun 2013
    Posts
    199
    i did the same changes, working fine with data not saving, but form still getting close.

    I need user not to leave the form wntil wnless provide all information

  4. #4
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Not really sure what "i did the same changes" means, but here's the kind of validation code June7 was talking about. Notice that I changed the To and From Field names to ToDate and FromDate; I did this because From is a Reserved Word, and using To, by itself, tends to confuse the Access Gnomes:

    Code:
    Private Sub Form_BeforeUpdate(Cancel As Integer)
    
     If Nz(Me.USD, "") = "" Then
       MsgBox "The USD Field Must Not Be Left Blank!"
       Cancel = True
       USD.SetFocus
       Exit Sub
     End If
     
    If Nz(Me.EUR, "") = "" Then
       MsgBox "The EUR Field Must Not Be Left Blank!"
       Cancel = True
       EUR.SetFocus
       Exit Sub
     End If
    
    If Nz(Me.ToDate, "") = "" Then
       MsgBox "The ToDate Field Must Not Be Left Blank!"
       Cancel = True
       ToDate.SetFocus
       Exit Sub
     End If
    
    If Nz(Me.FromDate, "") = "" Then
       MsgBox "The FromDate Field Must Not Be Left Blank!"
       Cancel = True
       FromDate.SetFocus
       Exit Sub
     End If
    
    End Sub

    Linq ;0)>

  5. #5
    drunkenneo is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Jun 2013
    Posts
    199
    I have coded it as on button click event as:
    Code:
    Private Sub save_Click()
       On Error GoTo Err_cmdClose_Click
    Me.Dirty = False
    MsgBox "Exchange Value Saved", vbInformation
    DoCmd.Close
    
    
    
    Exit_cmdClose_Click:
    Exit Sub
    
    Err_cmdClose_Click:
    If Err.Number = 3270 Then
    MsgBox "Data Incompelete Not able to save Data", vbCritical
    Else
    If Err.Number = 2001 Then
    MsgBox "Data Incompelete Not able to save Data", vbCritical
    Else
    MsgBox Err.Number
    MsgBox Err.Description, vbInformation, "Close"
    End If
    End If
    Resume Exit_cmdClose_Click
    End Sub
    And on form:
    Code:
    Private Sub Form_BeforeUpdate(Cancel As Integer)
    
    If Len(Me.indianInr & vbNullString) = 0 Then
      MsgBox "You need to fill INR Value", vbInformation
      'Cancel = True
      DoCmd.CancelEvent
       Me.indianInr.SetFocus
      End If
    
    
    
    If Len(Me.usdDollar & vbNullString) = 0 Then
      MsgBox "You need to fill USD Value", vbInformation
      'Cancel = True
      DoCmd.CancelEvent
      Me.usdDollar.SetFocus
    End If
    
    
    If Len(Me.dateFrom & vbNullString) = 0 Then
      MsgBox "You need to fill from Date", vbInformation
      'Cancel = True
      DoCmd.CancelEvent
       Me.dateFrom.SetFocus
    End If
    
    
    If Len(Me.Dateto & vbNullString) = 0 Then
      MsgBox "You need to fill to Date", vbInformation
      'Cancel = True
      DoCmd.CancelEvent
      Me.Dateto.SetFocus
    End If
    
    
    Me!dateAdded = Date
    
    
    End Sub
    As i get error message, i have thrown the message at error handling, which i dont find it right, is there any otherway to accomplish, the user cannot close the form until all the information is correct or else roll back.

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    What error message?

    Since you have a custom button to close the form, could just put all the validation code in the Click event.

    Do you want to allow user a "Cancel" option to abort the entire record entry/edit?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    drunkenneo is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Jun 2013
    Posts
    199
    Property not found and cannot restore unknown Error.

    No i dont want data to be cancelled, but i need the data to be edited but user cannot leave with a blank line textbox.

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    You are trying code in the button Click event?

    Step debug.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  9. #9
    drunkenneo is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Jun 2013
    Posts
    199
    i have achieved the task, thanks to you guys

  10. #10
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Quote Originally Posted by June7 View Post

    ...Since you have a custom button to close the form, could just put all the validation code in the Click event...
    Most developers don't advise this because

    1. In addition having a custom 'save/close' button you'd also need to disable the native 'Close Form' button, which tends to tick off experienced Access users
    2. You'd need another custom button to close the Form when saving a Record is not desired/required
    3. You'd need to disable the native 'Close Access' button, which also tends to tick off experienced Access users
    4. You'd need yet another custom button to close Access itself

    Not doing # 1 and # 3 could result in incomplete Records being saved, and # 2 and #4 are necessitated by # 1 and # 3. Simply easier to do validation for required Fields in the Form_BeforeUpdate event.

    Linq ;0)>

  11. #11
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Good points. I do all 1, 2, 3, 4. Easy to forget not everyone does what I do (which is, of course, the right way )

    All a matter of personal preference and who your clients are.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. foreign key not updating data from form
    By dave100 in forum Forms
    Replies: 1
    Last Post: 08-07-2013, 10:31 PM
  2. Replies: 10
    Last Post: 05-08-2012, 09:17 AM
  3. Replies: 2
    Last Post: 04-19-2012, 11:29 AM
  4. Replies: 1
    Last Post: 11-01-2011, 07:33 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums