Indicates previously input data

htadis

Registered User.
Local time
Tomorrow, 04:24
Joined
Dec 17, 2014
Messages
61
good day !

Need an assistance on below.

table name : Schedule
Field 1 = Vessel code
Field 2 = Voyage
Field 3 = ETA
Field 4 = berthed
Field 5 = Sailed

there is a query by using above table and data entry form based on that query.

need to add following facilitate

While data entering, if given voyage number is already exist for the particular vessel code, msg should be pop up immediately at that time saying " This voyage number is already exist"

How could this be manage ?

brgds
 
Use a DCount()

If DCOUNT( proper syntax and your criteria) > 0 indicates record(s) with that criteria already exist

Suggestion:
Use meaningful field names in your database/application. Easier to read and maintain. Use names with no embedded spaces or special characters. Use alphanumeric and "_" underscore only ----it will reduce frustration with syntax errors.
 
jdraw,

thanks for yr help. but it looks that does not fulfill my requirement. I need to get return not the number of records but whtr input data is already exist or not. That also should be limited to the vessel code. If same input for different code but not in the table should be allow to data entry.

eg.

Vsl code : GAA
Voyage : 001

if 001 is already exist under GAA, that should be notified by a msgbox.

Do not know whtr you got my point correctly.
 
htadis,

jdraw completely understood your requirement.

With the right criteria, if DCount returns 0 it means that 001/GAA has not been used, but if DCount returns 1 or more, it means that the 001/GAA exist.

You will need to apply two criteria in the DCount function. Do you now understand the application?

If Voyage is Text:
Code:
    If DCount("*", "[[COLOR="Blue"]TableName[/COLOR]]", "[Vessel code] = '" & Me.[COLOR="blue"]txtVesselCode [/COLOR]& "' " & _
                                  "AND " & _
                                  "[Voyage] = '" & Me.[COLOR="blue"]txtVoyage [/COLOR]& "'") = 0 _
    Then
        [COLOR="Blue"]' Allow edit[/COLOR]
    Else
        MsgBox "This record already exist"
    End If

If Voyage is Number:
Code:
    If DCount("*", "[[COLOR="blue"]TableName[/COLOR]]", "[Vessel code] = '" & Me.[COLOR="blue"]txtVesselCode [/COLOR]& "' " & _
                                  "AND " & _
                                  "[Voyage] = " & Me.[COLOR="blue"]txtVoyage[/COLOR]) = 0 _
    Then
        [COLOR="blue"]' Allow edit[/COLOR]
    Else
        MsgBox "This record already exist"
    End If
 
jdraw & vbainet

many thanks for yr help. Shall apply above and let u know the feedback.
 

Users who are viewing this thread

Back
Top Bottom